Back

api open weather can someone explain me this

Created 1 year ago
76 Views
2 Comments
MINALnJ0hoH
@MINALnJ0hoH
MINALnJ0hoH
@MINALnJ0hoHProfile is locked. Login
import requests
import json
api_key = "place the API key"
city=input()
url="https://api.openweathermap.org/data/2.5/weather?q=%s&appid=%s&units=metric"% (city, api_key)
#url = "https://api.openweathermap.org/data/2.5/onecall?lat=%s&lon=%s&appid=%s&units=metric" % (lat, lon, api_key)
response = requests.get(url)
data = json.loads(response.text)
#print(data)
print("the temperature in {} ".format(city)+str(data["main"]["temp"]))

Comments (2)
Please login to comment.