我很困惑,不知道如何解决这个错误。我试图抓住JSON响应列表中的每个名字。列表标记必须是整数。不str str的JSON响应
我的代码看起来像这样。
def extract_strucutres_ids(expected_structures):
response = requests.get(JIRA_REST + "/structures", verify=False)
response = response.json()
for structure in response['structures']:
print structure['name']
Json响应看起来像这样。
{
"structures": [{
"id": 165,
"name": "6.2 External Notifications Refactor",
"description": ""
}, {
"id": 364,
"name": "6.4 Day/Night Mode and Idle Scene Mode",
"description": "",
"readOnly": true
}, {
"id": 140,
"name": "ACC 5 Regression",
"description": ""
}
]
}
我总是收到List indicies must be integers, not str
。 Python版本2.7.10
请在'response ['strucutres']'中修正错字。应该是'结构'。 – codekaizer
,而'response'可能会像字典一样,它可能是一个字符串。这可以通过打印'response'类型来确认:'print(type(response))'。 –