Skip to content

Commit 7e94ec4

Browse files
authored
Create weather_fetcher.py
1 parent be78941 commit 7e94ec4

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

weather_fetcher.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import requests
2+
3+
API_KEY = "your_api_key_here" # Замени на свой ключ
4+
CITY = "Kyiv"
5+
URL = f"https://api.openweathermap.org/data/2.5/weather?q={CITY}&appid={API_KEY}&units=metric"
6+
7+
response = requests.get(URL)
8+
data = response.json()
9+
10+
if response.status_code == 200:
11+
temp = data['main']['temp']
12+
weather = data['weather'][0]['description']
13+
print(f"В {CITY} сейчас {temp}°C, {weather}")
14+
else:
15+
print("Ошибка получения данных:", data)

0 commit comments

Comments
 (0)