Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
295 views
in Technique[技术] by (71.8m points)

json.load() function doesn't work- Python

JSON load doesn't work for me whenever I run my code,


The code

import json

filename = 'eq_1_day_m1.json'
with open(filename) as f:
    all_eq_data = json.load(f)

readable_file = 'readable_eq_data.json'
with open(readable_file, 'w') as c:
    json.dump(all_eq_data, c, indent=4

It gives me this:

C:UsersPCAppDataLocalMicrosoftWindowsAppspython.exe "C:/Users/PC/PycharmProjects/Learning/Learning Matplotlib/eq_explore_data.py"
Traceback (most recent call last):
  File "C:UsersPCPycharmProjectsLearningLearning Matplotlibeq_explore_data.py", line 5, in 
    all_eq_data = json.load(f)
  File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0libjson\__init__.py", line 293, in load
    return loads(fp.read(),
  File "C:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0libencodingscp1252.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 10292: character maps to 

Process finished with exit code 1

I have my json file: 'eq_1_day_m1.json' if you are wondering

Can you help me?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...