teslariu

clima

Oct 11th, 2022
1,161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. #
  5. #https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API key}
  6.  
  7. import requests
  8. from datetime import datetime
  9. from pprint import pprint
  10.  
  11. r = requests.get("https://api.openweathermap.org/data/2.5/weather?lat=-34.61&lon=-58.38&units=metric&lang=es&appid=6ce13bc6d5a965e991adaea8fce8676a")
  12.  
  13. data = r.json()
  14. pprint(data)
  15.  
  16. print("\n\nHora del pronóstico")
  17. print(datetime.fromtimestamp(data['dt']))
  18.  
  19.  
  20. print("\nSalida del sol")
  21. print(datetime.fromtimestamp(data['sys']['sunrise']))
  22.  
  23. print("\nPuesta del sol")
  24. print(datetime.fromtimestamp(data['sys']['sunset']))
  25.  
  26.  
Advertisement
Add Comment
Please, Sign In to add comment