【发布时间】:2018-08-16 00:29:37
【问题描述】:
我正在从 API 获取数据并使用 requests 转换 JSON,然后从 dict 列表中的每个 dict 中提取一个值:
response = requests.get("http://api.open-notify.org/astros.json")
astros = response.json()
print(astros["number"])
[print(astronaut['name']) for astronaut in astros['people']]
输出根据需要提供名称列表,但在此之后是 6 个 None 值的列表;我不明白为什么。
【问题讨论】:
-
注。我在 Jupyter Notebook 中运行代码。
标签: python python-3.x