0
我有以下形式的在線數據:多詞典JSON文件大熊貓數據幀
{"headers": {"ai5": "3356", "debug": null, "random": null, "sd": "7.6"}, "post": {"event": "ggstart", "ts": "1462"}, "params": {}, "bottle": {"timestamp": "2016-05-09 02:00:00.033775", "game_id": "55107008"}}
{"headers": {"ai5": "8fa6", "debug": null, "random": null, "sd": "7.6"}, "post": {"event": "ggstart", "ts": "1475"}, "params": {}, "bottle": {"timestamp": "2016-05-09 02:00:00.004906", "game_id": "55107008"}}
我期待,我會讀它考慮到各行作爲JSON格式,並繼續將其添加到最後數據:
data = []
with open('new.json') as f:
for line in f:
print(line)
data.append(json.loads(line))
但我收到錯誤:
JSONDecodeError: Expecting value: line 2 column 1 (char 1)
能有人幫我在聯合國瞭解我在這裏失去了什麼重要的一點。
它實際上是JSON在這一行? 'print(line)'的輸出是什麼? – Robert