Python3 读取文件出错: 'gbk' codec can't decode byte 0x8

原创
2016/01/08 15:46
阅读数 1.6W

Python3 读取文件内容的时候出错:

for line in f.readlines():

UnicodeDecodeError: 'gbk' codec can't decode byte 0x8e in position 8: illegal multibyte sequence

这个时候给open添加一个参数即可

with open('/userList.txt', 'rt', encoding='utf-8') as f:


展开阅读全文
0 评论
1 收藏
2
分享
返回顶部
顶部