上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 25 下一页
摘要: Python可以使用open函数来实现文件的打开,关闭,读写操作; Python3中的open函数定义为: open(file, mode='r', buffering=None, encoding=None, errors=None, newline=None, closefd=True) 其中m 阅读全文
posted @ 2022-05-13 14:30 darling331 阅读(667) 评论(0) 推荐(0)
摘要: str1 = '2222222222222222asdasdadas22222222222' # 去除首位字符串 print(str1.strip('2')) str2 = ' asdasdadas ' # 去除首位字符串空格 print(str2.strip()) # replace() 替换中间 阅读全文
posted @ 2022-05-13 14:17 darling331 阅读(508) 评论(0) 推荐(0)
摘要: 使用openpyxl 库进行单元格大数据写入时(大概900字) 莫名的会丢失数据,有时候会丢失前面一点,有时候会丢失后面一点,打印了保存前的日志,和保存后的变量输出日志,都是完整的,但是保存到Excel之后,数据就不完整了,原因困扰了我很久,没有找到 import openpyxl # xlsxwr 阅读全文
posted @ 2022-05-13 14:10 darling331 阅读(668) 评论(0) 推荐(0)
摘要: dict.txt 迅雷不及掩耳盗铃之势 1 掩耳盗铃 2 铃儿响叮当 3 当仁不让 5 让世界充满爱 3 让世界充满爱 5 迅雷不及 0 迅雷 0 掩耳 0 盗铃 0 实现代码 # -*- ecoding: utf-8 -*- # @ModuleName: test002 # @Function: 阅读全文
posted @ 2022-05-09 01:13 darling331 阅读(145) 评论(0) 推荐(0)
摘要: 这篇文章已经很详细了,我就不造轮子了 阅读全文
posted @ 2022-05-07 00:28 darling331 阅读(44) 评论(0) 推荐(0)
摘要: count() 方法用于统计字符串里某个字符或子字符串出现的次数. st1 = input().upper() st2 = input().upper() print(st1.count(st2)) tips: 只要将所有字符串统一转化为大写或者小写,计算次数即可。 upper()全部转化为大写 l 阅读全文
posted @ 2022-05-07 00:25 darling331 阅读(473) 评论(0) 推荐(0)
摘要: def save_html(title): try: # 命名生成的html gen_html = '{}.html'.format(title) # 打开文件,准备写入 f = open(gen_html, 'w', encoding='UTF-8') # 准备相关变量 str1 = 'my na 阅读全文
posted @ 2022-05-07 00:21 darling331 阅读(249) 评论(0) 推荐(0)
摘要: system.yaml配置文件的内容: stage1: number_of_shards: 3 # 命中次数 file_size: 600 # 字节 stage2: is_rows: True # 是否需要limit rows: 6000 # limit行数 loggfile: "loggle.lo 阅读全文
posted @ 2022-05-07 00:16 darling331 阅读(148) 评论(0) 推荐(0)
摘要: 原代码 data_path = "sources/weibo_senti_100k.csv" data_list = open(data_path).readlines()[1:] 报错: UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xaf 阅读全文
posted @ 2022-05-07 00:09 darling331 阅读(548) 评论(0) 推荐(0)
摘要: pyMysql 链接使用后,不关闭报错 pymysql.err.InterfaceError: (0, ‘‘) 导致这个错误的原因是通过pymysql连接MySQL,没有关闭连接的操作,所以短时间内不会出问题,长时间保持这个连接会出现连接混乱。虽然看着自己的代码没错,还是会报pymysql.err. 阅读全文
posted @ 2022-05-07 00:04 darling331 阅读(532) 评论(0) 推荐(0)
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 25 下一页