我已經閱讀過許多例子。不幸的是,我不斷收到此錯誤,JSONDecodeError:期望','分隔符:第1行第43列(char 42)
錯誤:
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 43 (char 42)
JSON文件:
{"people": [{"name": "Scott", "from": "Nebraska", "website": "stackabuse.com"}, {"name": "Larry", "from": "Michigan", "website": "google.com"}, {"name": "Tim", "from": "Alabama", "website": "apple.com"}]}
而另一個單獨的JSON文件:
{"scores":[{"name":"Larry","result":["0":"24","1":"43","2":"56"]},{"name":"Tim","result":["0":"44","1":"29","2":"34"]}]}
Python代碼:
with open('data.json') as file:
data = json.load(file)
print(data)
你的第一個json文件沒有任何問題和打印數據。正如答案中所提到的那樣,它是第二個文件(單獨的json文件),它有一個列表,但提供了字典類型值。 –