Get weather data using python.

Published: 14 March 2021
on channel: wecodeinpython
591
11

Make Sure you have requests and json installed .
Code:-
import requests, json

city = "Delhi"
api_key = "Api key "
base_url = "https://api.openweathermap.org/data/2..."
url = base_url+"appid="+api_key+"&q="+city
response = requests.get(url)
x = response.json()
print(x)

if x['cod']!=404:
print("Weather :", x['weather'][0]['main'])
print("Temprature :", x['main']['temp'])
print("Min Temprature :", x['main']['temp_min'])
print("Max Temprature :", x['main']['temp_max'])

else:
print("city not found")


On this page of the site you can watch the video online Get weather data using python. with a duration of hours minute second in good quality, which was uploaded by the user wecodeinpython 14 March 2021, share the link with friends and acquaintances, this video has already been watched 591 times on youtube and it was liked by 11 viewers. Enjoy your viewing!