Advertisement
teslariu

openw

Aug 7th, 2021
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import requests
  4. from datetime import datetime
  5. from pprint import pprint
  6.  
  7. r = requests.get('https://api.openweathermap.org/data/2.5/weather?q=Buenos%20Aires,AR&units=metric&lang=es&appid=6ce13bc6d5a965e991adaea8fce8676a')
  8. data = r.json()
  9.  
  10. t = datetime.fromtimestamp(data['dt']).strftime("%d-%m-%y %H:%M:%S")
  11. data['dt'] = t
  12.  
  13. t = datetime.fromtimestamp(data['sys']['sunrise']).strftime("%d-%m-%y %H:%M:%S")
  14. data['sys']['sunrise'] = t
  15.  
  16. t = datetime.fromtimestamp(data['sys']['sunset']).strftime("%d-%m-%y %H:%M:%S")
  17. data['sys']['sunset'] = t
  18.  
  19. pprint(data)
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement