Python/JSON-TypeError:列表索引必须是整数或片,而不是str
我正在尝试从JSON数据中获取matchID,但是,得到了下面的TypeError。有人可以在这里建议解决方案吗 网址: 错误: TypeError:列表索引必须是整数或片,而不是strPython/JSON-TypeError:列表索引必须是整数或片,而不是str,python,json,Python,Json,我正在尝试从JSON数据中获取matchID,但是,得到了下面的TypeError。有人可以在这里建议解决方案吗 网址: 错误: TypeError:列表索引必须是整数或片,而不是str 提前感谢。这是因为data是一个json列表。因此,您需要: for d in data: matchID = d['matchID'] print (matchID) 明白了。谢谢你的回答。 for d in data: matchID = d['matchID'] pr
提前感谢。这是因为
data
是一个json列表。因此,您需要:
for d in data:
matchID = d['matchID']
print (matchID)
明白了。谢谢你的回答。
for d in data:
matchID = d['matchID']
print (matchID)