I want to display different png's from openweather.org depending on the weather description. I wrote the if statement but how do i write it in?

Viewed 37

for example:

if condition == "clear" or "clear sky":
    weather_png = "http://openweathermap.org/img/wn/01d@2x.png"
elif condition == "few clouds":
    weather_png = "http://openweathermap.org/img/wn/02d@2x.png"
elif condition == "scattered clouds":
    weather_png = "http://openweathermap.org/img/wn/03d@2x.png"
elif condition == "broken clouds" or "overcast clouds":
    weather_png = "http://openweathermap.org/img/wn/04d@2x.png"

What do i write so it opens weather_png up? i imported PIL and url.request but i cant figure it out.

1 Answers

You can use the standard library's webbrowser like this:

import webbrowser

webbrowser.open_new(weather_png)
Related