M
M
matveyvarg2016-10-14 13:31:50
Python
matveyvarg, 2016-10-14 13:31:50

Why does the script not print Cyrillic?

Output line:

('info', u'\u043c\u0440,\u0435\u0434,\u0432\u043d,\u043d\u043e')

Tried like .decode('utf-8'), throws UnicodeDecodeError.
If you use .encode('utf-8'), then there are no errors, but the characters are all early printed as a byte representation:
('info', '\xd0\xbc\xd1\x80,\xd0\xb5\xd0\xb4,\xd0\xb8\xd0\xbc,\xd0\xbe\xd0\xb4,\xd0\xbd\xd0\xbe')

How to output Russian characters?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Berloga, 2016-10-14
@matveyvarg

That's right, you're just printing a tuple, not a unicode string.
For python2:

>>> t = ('info', u'\u043c\u0440,\u0435\u0434,\u0432\u043d,\u043d\u043e')
>>> print t
('info', u'\u043c\u0440,\u0435\u0434,\u0432\u043d,\u043d\u043e')
>>> print t[1]
мр,ед,вн,но

If you want to beautifully display the unicode content of tuples, then here is a link to so
ps> if possible, go to python3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question