Advertisement
teslariu

openweather

Nov 3rd, 2021
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 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,AR&units=metric&lang=es&appid=6ce13bc6d5a965e991adaea8fce8676a')
  9. data = r.json()
  10.  
  11. pprint(data)
  12.  
  13. print("\nHora 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.  
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement