teslariu

openwe

Aug 7th, 2021
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 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/forecast?q=Buenos%20Aires,AR&cnt=10&units=metric&lang=es&appid=6ce13bc6d5a965e991adaea8fce8676a')
  8. data = r.json()
  9.  
  10. for dia in data['list']:
  11.     for c,v in dia.items():
  12.         if c == 'dt':
  13.             t = datetime.fromtimestamp(dia['dt']).strftime("%d-%m-%y %H:%M:%S")
  14.             dia['dt'] = t
  15.  
  16.  
  17. pprint(data)
  18.  
Advertisement
Add Comment
Please, Sign In to add comment