Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import attrdict
- # https://pypi.org/project/attrdict/
- data = {'coord': {'lon': 8.75, 'lat': 51.72}, 'weather': [{'id': 802, 'main': 'Clouds', 'description': 'scattered clouds', 'icon': '03d'}], 'base': 'stations', 'main': {'temp': 297.44, 'feels_like': 295.16, 'temp_min': 296.15, 'temp_max': 299.26, 'pressure': 1009, 'humidity': 53}, 'visibility': 10000, 'wind': {'speed': 5.1, 'deg': 80}, 'clouds': {'all': 40}, 'dt': 1591963557, 'sys': {'type': 1, 'id': 1304, 'country': 'DE', 'sunrise': 1591931194, 'sunset': 1591991006}, 'timezone': 7200, 'id': 2855745, 'name': 'Paderborn', 'cod': 200}
- ad = attrdict.AttrDict(data)
- lon, lat = ad.coord.lon, ad.coord.lat
- print(lon, lat)
- # wetter fast vergessen
- for weather in ad.weather:
- print(weather.main, weather.description)
- print(ad.sys.sunrise)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement