Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from datetime import datetime
- from pprint import pprint
- API_key = "6ce13bc6d5a965e991adaea8fce8676a"
- lat = -34.61
- lon = -58.38
- # Prnostico a 5 días
- # url = f"https://api.openweathermap.org/data/2.5/forecast?lat={lat}&lon={lon}&units=metric&lang=es&appid={API_key}"
- 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)
- datos = r.json()
- pprint(datos)
- print()
- print(f"Hora actual: {datetime.fromtimestamp(datos['dt'])}")
- print(f"Temperatura: {datos['main']['temp']:.1f}ºC")
- print(f"Sensación térmica: {datos['main']['feels_like']:.1f}ºC")
- 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