Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import requests
- from datetime import datetime
- from pprint import pprint
- r = requests.get('https://api.openweathermap.org/data/2.5/weather?q=Buenos%20Aires,AR&units=metric&lang=es&appid=6ce13bc6d5a965e991adaea8fce8676a')
- data = r.json()
- t = datetime.fromtimestamp(data['dt']).strftime("%d-%m-%y %H:%M:%S")
- data['dt'] = t
- t = datetime.fromtimestamp(data['sys']['sunrise']).strftime("%d-%m-%y %H:%M:%S")
- data['sys']['sunrise'] = t
- t = datetime.fromtimestamp(data['sys']['sunset']).strftime("%d-%m-%y %H:%M:%S")
- data['sys']['sunset'] = t
- pprint(data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement