Advertisement
DeaD_EyE

attrdict

Jun 13th, 2020
943
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. import attrdict
  2. # https://pypi.org/project/attrdict/
  3.  
  4.  
  5. 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}
  6.  
  7. ad = attrdict.AttrDict(data)
  8. lon, lat = ad.coord.lon, ad.coord.lat
  9. print(lon, lat)
  10.  
  11. # wetter fast vergessen
  12.  
  13. for weather in ad.weather:
  14.     print(weather.main, weather.description)
  15.  
  16. print(ad.sys.sunrise)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement