Advertisement
teslariu

clima

Oct 30th, 2021
137
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 pprint import pprint
  6. from datetime import datetime
  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. data = r.json()
  11. pprint(data)
  12.  
  13. print("\nHora y fecha del pronĂ³stico:")
  14. print(datetime.fromtimestamp(data['dt']))
  15.  
  16. print("\nSalida del Sol")
  17. print(datetime.fromtimestamp(data['sys']['sunrise']))
  18.  
  19. print("\nPuesta del Sol")
  20. print(datetime.fromtimestamp(data['sys']['sunset']))
  21.  
Advertisement
RAW Paste Data Copied
Advertisement