我正在尝试使用以下代码将.json文件作为字典导入:
import json
with open('StreamingHistory0.json') as json_file:
history = json.load(json_file)但是,我一直收到以下错误:
File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 97181: character maps to <undefined>此错误的原因是什么?是否有合适的修复方法?
发布于 2020-10-30 20:34:07
很可能是编码错误。试一试
with open('StreamingHistory0.json', encoding='utf-8')https://stackoverflow.com/questions/64608437
复制相似问题