上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 21 下一页
摘要: 对列表进行排序 if __name__ == "__main__": arr = [2, 5, 7, 5, 3, 22, 551, 11] # 对数值列表进行从小到大排序 arr.sort() # 然后进行反转 为从大到小 arr.reverse() # 这都是操作的原列表,不会产生新的列表,即不会 阅读全文
posted @ 2022-05-13 15:13 darling331 阅读(757) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(426) 评论(0) 推荐(0) 编辑
摘要: str1 = '2222222222222222asdasdadas22222222222' # 去除首位字符串 print(str1.strip('2')) str2 = ' asdasdadas ' # 去除首位字符串空格 print(str2.strip()) # replace() 替换中间 阅读全文
posted @ 2022-05-13 14:17 darling331 阅读(456) 评论(0) 推荐(0) 编辑
摘要: 使用openpyxl 库进行单元格大数据写入时(大概900字) 莫名的会丢失数据,有时候会丢失前面一点,有时候会丢失后面一点,打印了保存前的日志,和保存后的变量输出日志,都是完整的,但是保存到Excel之后,数据就不完整了,原因困扰了我很久,没有找到 import openpyxl # xlsxwr 阅读全文
posted @ 2022-05-13 14:10 darling331 阅读(323) 评论(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 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 这篇文章已经很详细了,我就不造轮子了 阅读全文
posted @ 2022-05-07 00:28 darling331 阅读(16) 评论(0) 推荐(0) 编辑
摘要: count() 方法用于统计字符串里某个字符或子字符串出现的次数. st1 = input().upper() st2 = input().upper() print(st1.count(st2)) tips: 只要将所有字符串统一转化为大写或者小写,计算次数即可。 upper()全部转化为大写 l 阅读全文
posted @ 2022-05-07 00:25 darling331 阅读(394) 评论(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 阅读(210) 评论(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 阅读(99) 评论(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 阅读(409) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 21 下一页