开发者

Convert Unicode Object to Python Dict

A request object that I'm dealing with has the following value开发者_Go百科 for the key "address":

  u"{u'city': u'new-york', u'name': u'Home', u'display_value': u'2 Main Street'}"

I need to operate on this unicode object as a dictionary. Unfortunately, json.loads() fails because it is not a json compatible object.

Is there any way to deal with this? Do I have to work with the the json.JSONDecoder object?


>>> ast.literal_eval(u"{u'city': u'new-york', u'name': u'Home', u'display_value': u'2 Main Street'}")
{u'city': u'new-york', u'name': u'Home', u'display_value': u'2 Main Street'}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜