尝试写入文件时出现JSONDecodeError

时间:2020-09-08 22:50:17

标签: python json

我正在尝试加载一个简单的geoJSON文件并将其转储为更清晰的格式...

import json

filename = 'usgs_earthquakes_today.json'
with open(filename) as f:
    all_eq_data = json.load(f)
    
readable_file = 'readable_eq_data_today.json'
with open(readable_file, 'w') as f:
    json.dump(all_eq_data, f, indent=4)

回溯返回:

JSONDecodeError                           Traceback (most recent call last)
<ipython-input-16-b742605a3e92> in <module>
      5 filename = 'usgs_earthquakes_today.json'
      6 with open(filename) as f:
----> 7     all_eq_data = json.load(f)
      8 
      9 readable_file = 'readable_eq_data_today.json'

不确定为什么会这样。

0 个答案:

没有答案