W
W
Whey2019-02-12 15:30:06
Python
Whey, 2019-02-12 15:30:06

How can one extract unicode characters from a string?

Good day. Please tell me how can I extract characters from unicode to UTF8.
Tried through decode - gives an error.

stroka = "d0\x92\xd1\x81\xd0\xb5\xd0\xbc \xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82"
print(stroka.decode("utf8"))

The error itself is:
AttributeError: 'str' object has no attribute 'decode'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AWEme, 2019-02-12
@Whey

>>> stroka = b"\xd0\x92\xd1\x81\xd0\xb5\xd0\xbc \xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82"
>>> stroka.decode('utf-8')
'Всем привет'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question