json - Non-english characters in python dictionary not printed correctly -
ok, first,yes have read http://www.joelonsoftware.com/articles/unicode.html
still have problems understanding why:
# -*- coding: utf-8 -*- import json a='ööö' b='ääß' print a+' '+b >>>ööö ääß print {'a':a,'b':b} >>>{'a': '\xc3\xb6\xc3\xb6\xc3\xb6', 'b': '\xc3\xa4\xc3\xa4\xc3\x9f'}
can assist in how have output
print {'a':a,'b':b} >>>{'a': 'ööö', 'b': 'ääß'}
i tried every combination of unicode(a), a.encode('utf-8'), unicode(a).encode('utf-8') , likes, no avail.
feeling stupid.
would appreciate if explain foor noobs, full examples.l
thanks lot!
>>> d = {'a': unicode('ööö', 'utf-8'), 'b': unicode('ääß', 'utf-8')} >>> print repr(d).decode("unicode-escape") {'a': u'ööö', 'b': u'ääß'}
Comments
Post a Comment