api open weather can someone explain me this
Created 1 year ago
76
Views
2
Comments
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"]))