【发布时间】:2017-12-03 11:21:03
【问题描述】:
{
"gameId": 32,
"participantIdentities": [
{
"player": {
"id": "123",
"name": "xxx",
},
"participantId": 1
},
{
"player": {
"id": "123",
"name": "yyyy",
},
"participantId": 2
}
]
"gameDuration": 143,
}
我正在尝试在 python 3 中的这个 json 文件中打印名称
list_id = []
for info in matchinfo['participantIdentities']['player']['name']:
list_id.append(info)
但我在下面收到以下错误
TypeError: list indices must be integers or slices, not str
如何获取'name'的内容?
【问题讨论】:
标签: json python-3.x api