ich will mit meinem Raspberry eine Bewässerung steuern.
Jetzt scheitere ich schon beim Import der Regenwahrscheinlichkeit von api.wunderground.com.
Ich bekomme folgende Fehlermeldung:
rain = parsed_json['forecast']['simpleforecast']['forecastday']['gpf_allday']
TypeError: list indices must be integers, not str
Das ist mein Script:
Code: Alles auswählen
import urllib2
import json
f = urllib2.urlopen('http://api.wunderground.com/api/xxxxxxxxxxxxxx/q/CA/hamburg.json')
json_string = f.read()
parsed_json = json.loads(json_string)
rain = parsed_json['forecast']['simpleforecast']['forecastday']['gpf_allday']
print (rain)
Danke
iop