我尝试使用python从thebluealliance.com网站. 这是我第一次尝试这样做,我成功地从网站上获得了一些数据,但这不是我所需要的。请求.json()正在为我返回一个列表,当我需要字典以便基于键进行分析时。我该怎么把它变成词典呢?我现在得到一个错误,说索引必须是整数,而不是字符串。在
这是我用来获取数据的代码。在
response = requests.get(TBA_URL + '/event/2019pncmp/teams/simple?X-TBA-Auth-Key=' + TBA_AUTH_KEY)
data = response.json()
print(data['city']) //Error is here.
示例data
:
从它的外观来看,
data
是一个字典列表,因此您需要遍历该列表来提取字典中的数据输出是
^{pr2}$或者使用列表理解
输出是
['Issaquah', 'Wilsonville']
相关问题 更多 >
编程相关推荐