When I try to convert unicode:
a = u"Тест"
To string:
str(a)
I got this error:
'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
I need str(a) to give me output:
>> str(a)
>> 'Тест'
Pick an encoding that can encode Cyrillic symbols, such as UTF-8:
>>> a = u'Тест'
>>> a.encode('utf-8')
'\xd0\xa2\xd0\xb5\xd1\x81\xd1\x82'
The ASCII table doesn't have code points for Cyrillic characters, so you need to specify an encoding explicitly.
But if all you want is just print the string, then what you should care about is the encoding of your terminal and the system font.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With