Advertisement
steve-shambles-2109

Get current weather

Oct 18th, 2019
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. """
  2. Python code snippets vol 35:
  3. 174-Get current weather
  4. stevepython.wordpress.com
  5.  
  6. pip3 install pyowm
  7. requires api key from: https://openweathermap.org/api
  8. """
  9. import pyowm
  10.  
  11. owm = pyowm.OWM('28c8c848ab4bece39561db462c462231')
  12.  
  13. # Search for current weather in London (Great Britain)
  14. observation = owm.weather_at_place('London,GB')
  15. w = observation.get_weather()
  16.  
  17. #print("Current weather:", w)
  18. print("Current status:", w.get_detailed_status())
  19. print("wind speed:", w.get_wind())
  20. print("Humidity %:", w.get_humidity())
  21. print("Temperature:", w.get_temperature('celsius'))
  22. print("Sunrise:", w.get_sunrise_time('iso'))
  23. print("Sunset:", w.get_sunset_time('iso'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement