我有这个代码:
import json
import requests
def crawl():
response = requests.get('https://swapi.dev/api/planets/?search=kamino')
api_results = json.loads(response.content)
print(api_results["results"])
crawl()
这给出了这个输出:
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"name": "Kamino",
"rotation_period": "27",
"orbital_period": "463",
"diameter": "19720",
"climate": "temperate",
"gravity": "1 standard",
"terrain": "ocean",
"surface_water": "100",
"population": "1000000000",
"residents": [
"http://swapi.dev/api/people/22/",
"http://swapi.dev/api/people/72/",
"http://swapi.dev/api/people/73/"
],
"films": [
"http://swapi.dev/api/films/5/"
],
"created": "2014-12-10T12:45:06.577000Z",
"edited": "2014-12-20T20:58:18.434000Z",
"url": "http://swapi.dev/api/planets/10/"
}
]
}
如何获得名称直径和地形?我已经搜索了很多,但我还没有找到任何可以帮助的东西,你们能帮帮我吗?