Warning: mkdir(): No space left on device in /var/www/tgoop/post.php on line 37

Warning: file_put_contents(aCache/aDaily/post/python_with_mohammad/--): Failed to open stream: No such file or directory in /var/www/tgoop/post.php on line 50
آموزش پایتون و برنامه نویسی@python_with_mohammad P.105
PYTHON_WITH_MOHAMMAD Telegram 105
مرحله ۵: دریافت اطلاعات آب‌وهوا از API
برای دریافت اطلاعات آب‌وهوا، از API سایت OpenWeatherMap استفاده می‌کنیم.

اول باید تو سایت OpenWeatherMap ثبت‌نام کنی و یه API Key دریافت کنی.

https://openweathermap.org/api


import requests

def get_weather(city):
api_key = 'API_KEY' # API Key خودت رو اینجا قرار بده
url = f'http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric'
response = requests.get(url)
data = response.json()

if data['cod'] == 200:
weather = data['weather'][0]['description']
temp = data['main']['temp']
return f'وضعیت آب‌وهوا در {city}: {weather}, دما: {temp}°C'
else:
return 'شهر مورد نظر یافت نشد.'

def get_city(update: Update, context: CallbackContext):
city = update.message.text
weather_info = get_weather(city)
update.message.reply_text(weather_info)



tgoop.com/python_with_mohammad/105
Create:
Last Update:

مرحله ۵: دریافت اطلاعات آب‌وهوا از API
برای دریافت اطلاعات آب‌وهوا، از API سایت OpenWeatherMap استفاده می‌کنیم.

اول باید تو سایت OpenWeatherMap ثبت‌نام کنی و یه API Key دریافت کنی.

https://openweathermap.org/api


import requests

def get_weather(city):
api_key = 'API_KEY' # API Key خودت رو اینجا قرار بده
url = f'http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric'
response = requests.get(url)
data = response.json()

if data['cod'] == 200:
weather = data['weather'][0]['description']
temp = data['main']['temp']
return f'وضعیت آب‌وهوا در {city}: {weather}, دما: {temp}°C'
else:
return 'شهر مورد نظر یافت نشد.'

def get_city(update: Update, context: CallbackContext):
city = update.message.text
weather_info = get_weather(city)
update.message.reply_text(weather_info)

BY آموزش پایتون و برنامه نویسی


Share with your friend now:
tgoop.com/python_with_mohammad/105

View MORE
Open in Telegram


Telegram News

Date: |

Telegram users themselves will be able to flag and report potentially false content. There have been several contributions to the group with members posting voice notes of screaming, yelling, groaning, and wailing in different rhythms and pitches. Calling out the “degenerate” community or the crypto obsessives that engage in high-risk trading, Co-founder of NFT renting protocol Rentable World emiliano.eth shared this group on his Twitter. He wrote: “hey degen, are you stressed? Just let it out all out. Voice only tg channel for screaming”. Don’t publish new content at nighttime. Since not all users disable notifications for the night, you risk inadvertently disturbing them. More>> The imprisonment came as Telegram said it was "surprised" by claims that privacy commissioner Ada Chung Lai-ling is seeking to block the messaging app due to doxxing content targeting police and politicians.
from us


Telegram آموزش پایتون و برنامه نویسی
FROM American