· 6 years ago · Oct 18, 2019, 09:34 PM
1"""
2Python code snippets vol 35:
3174-Get current weather
4stevepython.wordpress.com
5
6pip3 install pyowm
7requires api key from: https://openweathermap.org/api
8"""
9import pyowm
10
11owm = pyowm.OWM('28c8c848ab4bece39561db462c462231')
12
13# Search for current weather in London (Great Britain)
14observation = owm.weather_at_place('London,GB')
15w = observation.get_weather()
16
17#print("Current weather:", w)
18print("Current status:", w.get_detailed_status())
19print("wind speed:", w.get_wind())
20print("Humidity %:", w.get_humidity())
21print("Temperature:", w.get_temperature('celsius'))
22print("Sunrise:", w.get_sunrise_time('iso'))
23print("Sunset:", w.get_sunset_time('iso'))