![](/img/trans.png)
[英]How to fix the error 'UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 36188: character maps to <undefined>'
[英]How to fix: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 5518: character maps to <undefined> error
我想讀取 json 文件,然后將其加載到 Python 中的變量中,但它不斷出現此錯誤:
File "C:\Anaconda3\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 0x9d in position 5518: character maps to <undefined>```
My code looks like this:
with open('file.json') as f:
loadedfile = json.load(f)
Any suggestions?? I have looked at the other answers for similar questions but they all seem to be about text files not json files.
當我不小心嘗試加載一個實際上是 JPG 的文件時,我收到了這個錯誤。 仔細檢查文件路徑file.json
,您要open
的實際上是 JSON 文件。
with open('file.json') as f:
loadedfile = json.load(f)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.