错误 400 无法使用 Openweathermap 进行地理编码 API

Error 400 Nothing to geocode with Openweathermap API

我正在尝试为我的 python 应用程序使用 openweathermap,但出现问题。我对此 link 做了一个简单的请求:http://api.openweathermap.org/data/2.5/weather?q=London,fr&appid=[My Key]

我收到消息 Nothing to geocode 的错误 400。

你知道这是什么意思吗?

您也可以输入所在位置的经纬度,再尝试搭建。

api.openweathermap.org/data/2.5/weather?lat=35&lon=139 Like This ^

它给您错误的原因是因为您向 API 询问法国伦敦 (q=London,fr) 的数据。 fr 部分是国家代码。

您只需将 fr 更改为 uk 即可! link 将是 http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=[yourID]

您必须在 URL 之后添加 latlon,然后添加您的 API key, 就可以了:

https://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&APPID=YOUR_API_KEY