2017-12-23 14 views
0

現在の気象データを緯度と経度で取得しようとしています。ここに私のPythonコードの一部です:openweathermap APIでエラーが発生しました

import requests 

def get_weather(lat, lon): 
    return requests.get(f'http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon},fr&appid=<MY API KEY>').json() 

print(get_weather(96.95, 21.83)) 

それは、これを返します。

{"cod":"400","message":"96.95 is not a float"} 

あなたは間違って何を知っていますか?

答えて

0

問題が解決しました。

f'http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon},fr&appid=<MY API KEY>' 

正しいものは次のとおりです:

f'http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid=<MY API KEY>' 

問題は、URLました

関連する問題