python运行报错:
UnicodeDecodeError: 'gbk' codec can't decode byte 0x90 in position 28: illegal multibyte sequence

原代码:
def read_data(self):
with open(self.file_path) as fp:
data = json.load(fp)
return data

解决方式:
需要将读取的文件编码格式改为 utf-8

修改为:
def read_data(self):
with open(self.file_path,encoding='utf-8') as fp:
data = json.load(fp)
return data

运行正确!

 posted on 2021-03-25 19:54  叶叶酱  阅读(572)  评论(0编辑  收藏  举报