Advertisement
teslariu

clima

Dec 21st, 2021
982
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import requests
  5. from datetime import datetime
  6. from pprint import pprint
  7.  
  8. url = "https://api.openweathermap.org/data/2.5/weather?q=Buenos%20Aires,AR&units=metric&lang=es&appid=6ce13bc6d5a965e991adaea8fce8676a"
  9. r = requests.get(url)
  10. datos = r.json()
  11. pprint(datos)
  12.  
  13. print("\n\n")
  14.  
  15. print("Hora del pronóstico:")
  16. print(datetime.fromtimestamp(datos['dt']))
  17.  
  18. print("Salida del sol:")
  19. print(datetime.fromtimestamp(datos['sys']['sunrise']))
  20.  
  21. print("Puesta del sol:")
  22. print(datetime.fromtimestamp(datos['sys']['sunset']))
  23.  
  24. print("Sensación térmica:")
  25. print("{:.1f}ºC".format(datos['main']['feels_like']))
  26.  
  27.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement