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

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

for line in f.readlines():code

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

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

with open('/userList.txt', 'rt', encoding='utf-8') as f:
相关文章
相关标签/搜索