Ok.
data = loc.sun(date.today()).items()
gibt aus:
dict_items([('noon', datetime.datetime(2021, 3, 8, 12, 40, 56, tzinfo=<DstTzInfo 'Europe/Zurich' CET+1:00:00 STD>)), ('dawn', datetime.datetime(2021, 3, 8, 6, 24, 33, tzinfo=<DstTzInfo 'Europe/Zurich' CET+1:00:00 STD>)), ('sunrise', datetime.datetime(2021, 3, 8, 6, 54, 53, tzinfo=<DstTzInfo 'Europe/Zurich' CET+1:00:00 STD>)), ('sunset', datetime.datetime(2021, 3, 8, 18, 26, 59, tzinfo=<DstTzInfo 'Europe/Zurich' CET+1:00:00 STD>)), ('dusk', datetime.datetime(2021, 3, 8, 18, 57, 19, tzinfo=<DstTzInfo 'Europe/Zurich' CET+1:00:00 STD>))])
sun1 = data["sunset"]
gibt diesen Fehler:
Traceback (most recent call last):
File "./test.py", line 31, in <module>
sun1 = data["sunset"]
TypeError: 'dict_items' object is not subscriptable
Laut
https://www.python-kurs.eu/dictionaries.php müssten die Daten mit : getrennt sein. Liegt das an dem?
Edit:
Mit
data = loc.sun(date.today())
bekomme ich folgenden Output ^^
2021-03-08 18:26:59+01:00
Das ist ja schonmal etwas
