From daa57fd88562589ff4e6d2ba0cb68943c7778c3b Mon Sep 17 00:00:00 2001 From: Luiz Fernando Nunes Date: Mon, 16 Dec 2019 15:03:29 -0300 Subject: [PATCH] Update Weather correcting the error handling the url --- SimplecOne/weather.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SimplecOne/weather.py b/SimplecOne/weather.py index fd77128..1fb3b79 100755 --- a/SimplecOne/weather.py +++ b/SimplecOne/weather.py @@ -23,7 +23,8 @@ ######################################################## main_url = "http://api.openweathermap.org/data/2.5/weather?" -url = main_url+"APPID={}&q={},{}".format(API_KEY,CITY,COUNTRY) +filtered_city = CITY.replace(" ", "%20") +url = main_url+"APPID={}&q={},{}".format(API_KEY,filtered_city,COUNTRY) metrics = {"k":"&units=default","c":"&units=metric","f":"&units=imperial"} for key,value in metrics.items(): if UNITY == key: @@ -47,4 +48,4 @@ weather.write("wind>"+str(j["wind"]["speed"])+"\n") weather.write("update>"+datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')+"\n") -weather.close() \ No newline at end of file +weather.close()