I\'m working with a counter from collections import Counter and I want to print its values using matplotlib.pylot.
When I try to do it usin
So, i thought the op asked for unicode, not for UTF-8. Unicode is not an encoding, it's just actual text. So would this not be more accurate and/or readable?
unidict = {unicode(k): unicode(v) for k, v in strdict.items()}
If you're using Python 2.7, you can use a dict comprehension:
unidict = {k.decode('utf8'): v.decode('utf8') for k, v in strdict.items()}
For older versions:
unidict = dict((k.decode('utf8'), v.decode('utf8')) for k, v in strdict.items())
(This assumes your strings are in UTF-8, of course.)