我需要将多个JSON数组作为字符串处理,并转换为Python中的列表。以下是我尝试过的:
array = '[{"drinks": ["coffee", "tea", "water"]}],' \
'[{"drinks": ["coffee", "tea", "water"]}]'
data = json.loads(array)
print(data)
这将生成以下错误:
Traceback (most recent call last): File
"C:/Users/aessam/Desktop/sen/josnre.py", line 10, in <module>
data = json.loads(array) File "C:\Users\aessam\AppData\Local\Programs\Python\Python35\lib\json\__init__.py",
line 319, in loads
return _default_decoder.decode(s) File "C:\Users\aessam\AppData\Local\Programs\Python\Python35\lib\json\decoder.py",
line 342, in decode
raise JSONDecodeError("Extra data", s, end) json.decoder.JSONDecodeError: Extra data: line 1 column 41 (char 40)
有什么问题,我该怎么解决?你知道吗
数组中没有
[]
个元素 e、 现在是这样的而不是
试试这个
相关问题 更多 >
编程相关推荐