Answer the question
In order to leave comments, you need to log in
How to use unicode in python2.7?
Hello. Always used python3 (normal work with unicode is just one of the reasons).
Now I want to use the sccrapy library, but it is only for the 2nd branch.
I figured out the library itself more or less, but since I need to parse the site with Cyrillic, I get this
>>>s
u'\u043d\u0430'
>>>s.encode('utf-8')
'\xd0\xbd\xd0\xb0'
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
>>>s.encode('windows-1251')
'\xed\xe0'
Answer the question
In order to leave comments, you need to log in
u'\u043d\u0430' is the Unicode representation of the string (everything that starts with u'')
The encode method allows you to encode Unicode into the encoding we need, for example, to write to a file, etc.
At one time, this article helped a lot: habrahabr.ru/post/135913
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question