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.
 
 

25 lines
695 B

import requests
import json
#klíč získáte na https://home.openweathermap.org/api_keys
KLIC = "cdcbb82b14e8e3e85117686c68e19a5b"
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 odkaz: {url}")
odpoved = requests.get(url)
odpoved.raise_for_status()
data = odpoved.json()
#print(json.dumps(data,indent=4,ensure_ascii=False))
popis = data["weather"][0]["description"]
teplota = data["main"]["temp"]
owm_mesto = data["name"]
print(f"Město: {owm_mesto} (napsáno:{MESTO})")
print(f"Teplota: {teplota}°C")
print(f"Popis: {popis}")