Answer the question
In order to leave comments, you need to log in
How do encodings work?
I can't figure out how coding works in python. The function decode(bytes_)
throws an error, trying to decode cp1251, I set encoding='utf-8', the same error, and in the same file cp1251. From a psycho, I import the utf_8 library directly and use decode from there. Same error, absolutely. Sometimes I manage to somehow magically make it work, but this time the error comes out when I try to print the already decoded text using print, and the error is the same, only it is displayed on the stack, as from the print (text) function.
python 3.7
decode(bytes_, encoding='utf-8')
Answer the question
In order to leave comments, you need to log in
text = b'\xef\xf0\xe8\xe2\xe5\xf2'
print(text.decode('cp1251'))
text - text encoded cp1251
decode - specify what encoding the text is in, convert to a readable encoding (utf-8 like)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question