On Friday, April 14, 2017 at 3:27:29 PM UTC+1, Kasper wrote: > every time i run the program i get this messeage: > > Traceback (most recent call last): > File "smartmirror.py", line 159, in get_weather > temprature2 = "%S%S" % (str(int(weather_obj['currently']['temperature'])), > degree_sign) > KeyError: 'currently' > Error: 'currently'. Cannot get weather. > > How do i fix that? > > Here is the program: > > r = requests.get(weather_req_url) > weather_obj = json.loads(r.text) > > degree_sign= u'\N{DEGREE SIGN}' > temperature2 = "%s%s" % > (str(int(weather_obj['currently']['temperature'])), degree_sign)
Find the correct name for the key by printing out `weather_obj`. At least I think so, as the line above does not match the line that you've given. Kindest regards. Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list