Python how to handle # in a dictionary

Posted by Jack on Stack Overflow See other posts from Stack Overflow or by Jack
Published on 2010-05-30T14:04:31Z Indexed on 2010/05/30 14:12 UTC
Read the original article Hit count: 227

Filed under:
|
|

I've got some json from last.fm's api which I've serialised into a dictionary using simplejson. A quick example of the basic structure is below.

{ "artist":
    "similar": { 
        "artist": {
            "name": "Blah",
            "image": {"#text":"URLHERE","size": "small"}
            "image": {"#text":"URLHERE","size": "medium"}
            "image": {"#text":"URLHERE","size": "large"}
         }
     }
}

Any ideas how I can access the image urls of various different sizes. My attempts at accessing the #text variable don't seem to work because python doesn't appear to like #'s in the names. And any ideas how I can easily get the url for the depending on the size?

Thanks,
Jack

© Stack Overflow or respective owner

Related posts about python

Related posts about JSON