You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
665 B

import requests
import json
#Klíč získate na https://home.openweathermap.org/api_keys
KLIC = "<API_KLIC>"
MESTO = input("Zadej město:")
# & = AltGR+C; {|} = AltGR+B|N
url1 = f"https://api.openweathermap.org/data/2.5/"
url2 = f"weather?q={MESTO}&appid={KLIC}&units=metric"
url = url1+url2
print(f"Otevírám stránku: {url}")
odpoved = requests.get(url)
odpoved.raise_for_status()
data = odpoved.json()
print(json.dumps(data,indent=4,ensure_ascii=False))
teplota = data["main"]["temp"]
popis = data["weather"][0]["description"]
owm_mesto = data["name"]
print(f"Město: {owm_mesto} (napsáno:{MESTO})")
print(f"Teplota: {teplota}°C")
print(f"Popis: {popis}")