Mayur Koshti Mayur Koshti - 1 year ago 158
Python Question

Russian character decoding in python

This question only for python:

I have a city name in a string in Russian language and which is in Unicode form like,




How to get original text instead of unicode characters?

Note: Do not use any import module

vz0 vz0
Answer Source
>>> a=u"\u041C\u043E\u0441\u043A\u0432\u0430"
>>> print a

Your string is a unicode string because each character/code point with \u is only usable from a unicode string, you should prefix the string with u. Otherwise is a regular string and each \u counts as a regular ascii character:

>>> len(a)
>>> b="\u041C\u043E\u0441\u043A\u0432\u0430"
>>> len(b)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download