2017-12-23 15 views
0

위도와 경도로 현재 기상 데이터를 얻으려고합니다.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했다