Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
11 lines (11 loc) · 595 Bytes

File metadata and controls

11 lines (11 loc) · 595 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
//importing requests package to deal with http
import requests
city = input("Enter your city name: ")
// To get API --> https://openweathermap.org/
api_address = "http://api.openweathermap.org/data/2.5/weather?appid={ADD-YOUR-API-KEY}&q={}".format(city)
//used get method to conect with the API
// json method is used to convert JSON into python format JSON.
json_data = requests.get(api_address).json()
//indexing the weather and temp from the JSON
output = json_data['weather'][0]['main'] 'and temperature is ' json_data['main']['temp']
print("The weather is {} in {}.").format(output, city)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.