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
- lat = -34.61
- lon = -58.38
- API_key = "6ce13bc6d5a965e991adaea8fce8676a"
- url = f"https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&units=metric&lang=es&appid={API_key}"
- r = requests.get(url)
- # Pronóstico crudo
- datos = r.json()
- pprint(datos)
- print(f"Fecha y hora del pronóstico: {datetime.fromtimestamp(datos['dt'])}")
- print(f"Salida del Sol: {datetime.fromtimestamp(datos['sys']['sunrise'])}")
- print(f"Puesta del Sol: {datetime.fromtimestamp(datos['sys']['sunset'])}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement