ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

python读写文件

2020-01-22 21:54:45  阅读:61  来源: 互联网

标签:文件 sequence python data 读写 lines line txt open


f = open("./data/test.txt","r")
lines = f.readlines()
for line in lines:
    print(line)

 

UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 2729: illegal multibyte sequence 解决方案:

f = open("./data/happy.txt", "r", encoding='utf-8')

 

 

标签:文件,sequence,python,data,读写,lines,line,txt,open
来源: https://www.cnblogs.com/lucifer1997/p/12229733.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有