我正在使用代码:
getSource = requests.get("https://api.twitch.tv/kraken/streams")
text = json.loads(getSource.text)
print text["streams"]["_links"]["_self"]
text 是我通过调用 json.loads 得到的字典。然后我尝试获取嵌套值,最终尝试获取 url 但出现此错误:
Traceback (most recent call last):
File "Twitch Strim.py", line 11, in <module>
print text["streams"]["_links"]["_self"]
TypeError: list indices must be integers, not str
我该如何纠正?