codeObjC codeObjC - 5 months ago 48
Python Question

String Dict to Unicode coversion

I am new to python. I was wondering if there are any intuit functionality that I can use to go from string dict to unicode dict.


{'name': 'Lexus', 'model': 'GS F'}

Expected output:

{u'name': u'Lexus', u'model': u'GS F'}

Any comments / forwards to resources are welcomed.

>>> d={'name': 'Lexus', 'model': 'GS F'}
>>> d={k.decode('utf8'): v.decode('utf8') for k, v in d.items()}

output :

{u'model': u'GS F', u'name': u'Lexus'}