Advertisement
teslariu

se

Aug 28th, 2021
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  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. r = requests.get("https://api.openweathermap.org/data/2.5/weather?q=Buenos%20Aires&units=metric&lang=es&appid=6ce13bc6d5a965e991adaea8fce8676a")
  9. datos = r.json()
  10. pprint(datos)
  11. print("Hora del pronostico")
  12. hora = datetime.fromtimestamp(datos['dt'])
  13. print(hora)
  14. print("Amanecer")
  15. hora = datetime.fromtimestamp(datos['sys']['sunrise'])
  16. print(hora)
  17. print("Ocaso")
  18. hora = datetime.fromtimestamp(datos['sys']['sunset'])
  19. print(hora)
  20.  
  21. """
  22. {'base': 'stations',
  23. 'clouds': {'all': 0},
  24. 'cod': 200,
  25. 'coord': {'lat': -34.6132, 'lon': -58.3772},
  26. 'dt': 1630183626,
  27. 'id': 3435910,
  28. 'main': {'feels_like': 17.64,
  29.          'humidity': 62,
  30.          'pressure': 1023,
  31.          'temp': 18.15,
  32.          'temp_max': 21.63,
  33.          'temp_min': 15.85},
  34. 'name': 'Buenos Aires',
  35. 'sys': {'country': 'AR',
  36.         'id': 8224,
  37.         'sunrise': 1630145853,
  38.         'sunset': 1630186335,
  39.         'type': 1},
  40. 'timezone': -10800,
  41. 'visibility': 10000,
  42. 'weather': [{'description': 'cielo claro',
  43.              'icon': '01d',
  44.              'id': 800,
  45.              'main': 'Clear'}],
  46. 'wind': {'deg': 110, 'speed': 4.12}}
  47. """
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement