Sunday, 15 January 2012

Python: Search in dict embedded in list -



Python: Search in dict embedded in list -

sorry badly english. hello. how can url list?

[{u'highlighted': [], u'image_permalink': u'http://bluebeetlezar.tumblr.com/image/101630187766', u'reblog_key': u'rwjdee41', u'format': u'html', u'timestamp': 1414973540, u'note_count': 0, u'tags': [u'train', u'railway', u'station', u'silent', u'morning'], u'photos': [{u'caption': u'', u'original_size': {u'url': u'http://38.media.tumblr.com/aa3018b3d8b147dc49e4b407b62f2b94/tumblr_nefsklmdsb1s385n2o1_1280.jpg', u'width': 640, u'height': 640}, u'alt_sizes': [{u'url': u'http://38.media.tumblr.com/aa3018b3d8b147dc49e4b407b62f2b94/tumblr_nefsklmdsb1s385n2o1_1280.jpg', u'width': 640, u'height': 640}, {u'url': u'http://33.media.tumblr.com/aa3018b3d8b147dc49e4b407b62f2b94/tumblr_nefsklmdsb1s385n2o1_500.jpg', u'width': 500, u'height': 500}, {u'url': u'http://38.media.tumblr.com/aa3018b3d8b147dc49e4b407b62f2b94/tumblr_nefsklmdsb1s385n2o1_400.jpg', u'width': 400, u'height': 400}, {u'url': u'http://38.media.tumblr.com/aa3018b3d8b147dc49e4b407b62f2b94/tumblr_nefsklmdsb1s385n2o1_250.jpg', u'width': 250, u'height': 250}, {u'url': u'http://33.media.tumblr.com/aa3018b3d8b147dc49e4b407b62f2b94/tumblr_nefsklmdsb1s385n2o1_100.jpg', u'width': 100, u'height': 100}, {u'url': u'http://33.media.tumblr.com/aa3018b3d8b147dc49e4b407b62f2b94/tumblr_nefsklmdsb1s385n2o1_75sq.jpg', u'width': 75, u'height': 75}]}], u'id': 101630187766, u'post_url': u'http://bluebeetlezar.tumblr.com/post/101630187766/stasiun-gondangdia-in-the-morniiiiinnngg', u'caption': u'<p>stasiun gondangdia in morniiiiinnngg :) #railway #station #train #morning #silent</p>', u'state': u'published', u'short_url': u'http://tmblr.co/z2eiht1ufepzs', u'date': u'2014-11-03 00:12:20 gmt', u'link_url': u'http://instagram.com/p/u6sfevmnj2/', u'type': u'photo', u'slug': u'stasiun-gondangdia-in-the-morniiiiinnngg', u'blog_name': u'bluebeetlezar'}]

i wanna utilize .get, info - list. how can extract url anoter way? or list -> dict? (dict() doesnt work or stupid).

' your_list[0]['image_permalink'] # -> http://bluebeetlezar.tumblr.com/image/101630187766

your_list[0]['photos'][0]['original_size']["url"] # -> http://38.media.tumblr.com/aa3018b3d8b147dc49e4b407b62f2b94/tumblr_nefsklmdsb1s385n2o1_1280.jpg

you have single element within list dict, utilize your_list[0] access utilize keys whatever url need.

in [27]: your_list[0]['photos'][0]['original_size']['url'] out[27]: 'http://38.media.tumblr.com/aa3018b3d8b147dc49e4b407b62f2b94/tumblr_nefsklmdsb1s385n2o1_1280.jpg'

python list dictionary tumblr

No comments:

Post a Comment