2020年3月31日

Python逐行读取文件内容

摘要: Python逐行读取文件内容 代码来源: Python参考手册 f = open("foo.txt") # 返回一个文件对象line = f.readline() # 调用文件的 readline()方法while line: print line, # 后面跟 ',' 将忽略换行符 # print 阅读全文

posted @ 2020-03-31 22:18 shuzihua 阅读(3479) 评论(0) 推荐(0) 编辑

python3 open txt的UnicodeDecodeError: 'gbk' codec问题解决方案

摘要: python3 open txt的UnicodeDecodeError: 'gbk' codec问题解决方案先直截了当给出解决方案,在程序开头加上:import _locale_locale._getdefaultlocale = (lambda *args: ['zh_CN', 'utf8'])1 阅读全文

posted @ 2020-03-31 22:08 shuzihua 阅读(1942) 评论(0) 推荐(0) 编辑

导航