私信  •  关注

Alan Dyke

Alan Dyke 最近创建的主题
Alan Dyke 最近回复了
5 年前
回复了 Alan Dyke 创建的主题 » python中如何从api解析应答到dict not list

你的回答是一系列的口述。如果你想提取一个项目,你可以说

response_dict=r.json()[0]

response = r.json()
response_dict = dict([ (i['id'], i) for i in response])

或者如果您喜欢使用“name”参数:

response_dict = dict([ (i['name'], i) for i in response ])