Hi! i need some help with a program in python on Raspberry pi3.

breamoreboy at gmail.com breamoreboy at gmail.com
Fri Apr 14 10:57:00 EDT 2017


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.


More information about the Python-list mailing list