【发布时间】:2016-02-13 17:28:58
【问题描述】:
从今天早上开始,我一直在思考如何从 here 获取此 json 答案的“层级”。我一直在尝试这个:
url = #given
response = requests.get(url)
data = json.loads(response.text)
for ids in data:
print(ids['tier'])
它一直告诉我这个:print(ids['tier']) TypeError: string indices must be integers
【问题讨论】:
-
ids不是字典,而是字符串。 -
尝试使用 JSON 查看器/美化器,例如 codebeautify.org/jsonviewer 来帮助您可视化 JSON 中的结构。
标签: python json parsing web python-requests