I was wondering if there are any intuit functionality that I can use to go from string dict to unicode dict.
Input:
{'name': 'Lexus', 'model': 'GS F'}
Expected output:
{u'name': u'Lexus', u'model': u'GS F'}
1 Answer 1
>>> 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'}
answered Oct 20, 2016 at 22:56
Hisham Karam
1,32817 silver badges29 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.
lang-py
strtounicode?from __future__ import unicode_literals.