調べてみたら、JSONファイルに問題があり、シングルクォーテーションをダブルクォーテーションにしたら動きました。
<Python>
import json
from os import path
a = path.join(path.dirname(__file__), 'test.json')
json_open = open(a, 'r')
json_load = json.load(json_open)
print(json_load)
<エラー内容>
Traceback (most recent call last):
File "/Users/xxxx/JSON01.py", line 12, in <module>
json_load = json.load(json_open)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 293, in load
return loads(fp.read(),
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 2 column 3 (char 4)
0 件のコメント:
コメントを投稿