python - Getting list and dict values - Django -
i have problem. new django , trying figure out how can specific values out of list , dict views.py. have following dict output:
{'meta_title': u'alaska state fair events', 'varos_id': 2886429l, 'longitude': -149.13053600000001, 'name': u'palmer', 'thumbnail_id': 8406l, 'image': u'photologue/photos/2c18fe09-275b-4770-aab6-230cff72b2ee.jpg', 'orszag_id': u'us', 'helyszin': u'alaska state fair, 2075 glenn highway palmer, ak 99645, united states ', 'slug': u'alaska-state-fair-palmer-ak', 'latitude': 61.580159999999999, 'allam_id': u'ak', 'nev': u'alaska state fair, palmer, ak', 'id': 2886429l} what want quite simple. want address variables image=szorakozohelyquery('image') result in image=photologue/photos/2c18fe09-275b-4770-aab6-230cff72b2ee.jpg
is there easy way this? easiest way list?
d.get('image','default value') willprevent key error if key not there in dictionary d
>>> d ={'image':'a.jpg'} >>> d.get('image','not found') 'a.jpg' >>> d={} >>> d.get('image','not found') 'not found' >>>
Comments
Post a Comment