Code: Select all
import requests
from os import *
api_address = "https://api.openweathermap.org/data/2.5/weather?id=bfbe606c8d661478b8132b49eee8051a"
json_data = requests.get(api_address).json()
# json_data = json_data.json()
def temp():
temperature = round(json_data['main']['temp']-273.1)
return temperature
def des():
description = json_data["weather"][0]["description"]
return description
print(temp())
print(des())
Code: Select all
line 9, in temp
temperature = round(json_data['main']['temp']-273.1)
KeyError: 'main'