Постоянная ошибка Traceback (most recent call last): File "/home/pi/phidget.py", line 15, in <module> weather = data["list"][0] KeyError: 'list'
Здравствуйте! У меня такая же ошибка. Код ниже: Код (Python): import requests import json url = "http://api.openweathermap.org/data/2.5/forecast" payload = { "lat":"55.7440", "lot":"37.6568", "units":"metric", "appid":"ВВЕСТИ_СВОЙ_ИД_КЛЮЧА", } res = requests.get(url, params=payload) data = json.loads(res.text) weather = data["list"][0] def pars_weather(weatherType, timeRange, measurementUnits): if (weatherType in weather) and ( timeRange in weather[weatherType].keys() ): print( weatherType, ": ", weather[weatherType][timeRange], measurementUnits, ) else: print(weatherType, ": ", "none") pars_weather("clouds", "all", "%") pars_weather("rain", "3h", "mm") pars_weather("snow", "3h", "mm") print("temp: ", weather["main"]["temp"], "C") Какую тему в Python необходимо прочитать, чтобы исправить ошибку: Код (Python): weather = data["list"][0] KeyError: 'list'