Displaying unicode characters in Python 3

283 Views Asked by At

I have issues with displaying Unicode characters. As an output I have this list (only on online IDEs):

[u'\u0413', u'\0434', u'\043b']

How can I convert this sequence to normally visible text? I have # -*- coding: utf-8 -*- in header and also each string marked as Unicode like u'String'

I tried to use code: myList = repr([x.encode(sys.stdout.encoding) for x in lst]).decode('string-escape') but it's not working and output still the same.

1

There are 1 best solutions below

1
On BEST ANSWER

In Python 3, this will work directly:

>>> [u'\u0413', u'\0434', u'\043b']
['Г', '#4', '#b']

In Python 2, you can use the print statement to print individual values:

>>> for val in [u'\u0413', u'\0434', u'\043b']:
...   print val
... 
Г
#4
#b