【发布时间】:2017-09-30 16:28:54
【问题描述】:
当我运行这个时:
import json, sys
with open('/Users/mac/Desktop/export-2017-04-28-0235-25014395ac.json', 'r') as json_data:
d = json.load(json_data)
print(d)
它返回一个错误,我不确定要怎么想。我已经完成了研究,但我不确定我是否理解出了什么问题。如果有人可以帮助我,那就太好了。
这是错误:
Traceback (most recent call last):
File "/Users/mac/Desktop/untitled.py", line 4, in <module>
d = json.load(json_data)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 296, in load
return loads(fp.read(),
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 39966: ordinal not in range(128)
[Finished in 0.5s with exit code 1]
[shell_cmd: python3 -OO -u "/Users/mac/Desktop/untitled.py"]
[dir: /Users/mac/Desktop]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
【问题讨论】:
标签: python python-3.x debugging error-handling