我正在尝试将存储在JSON文件中的多个JSON帧导入到python中。 我的代码是:
import json
import array
with open("J1.json") as J:
j_Data = json.load(J)
print j_Data
错误:
Traceback (most recent call last):
File "/home/abhi/Desktop/CSS HTML/Python Mongo/JSONtoMongoDB.py", line 9, in <module>
j_Data = json.load(J)
File "/usr/lib/python2.7/json/__init__.py", line 290, in load
**kw)
File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 369, in decode
raise ValueError(errmsg("Extra data", s, end, len(s)))
ValueError: Extra data: line 1 column 1113 - line 1 column 2225 (char 1112 - 2224)
我的JSON文件数据如下:
答案 0 :(得分:1)
如果您可以在JSON文件中创建JSON帧数组:
[{"yphthd": "123.32"} , {"yphthd": "123.32"}, ... {"yphthd": "123.32"}]
然后加载它:
with open("J1.json") as J:
j_Data = json.load(J)
print j_Data