Here is the code:
# coding: utf-8 string = '\u0434\u0438\u0435\u0442\u0430, \u0434\u0438\u0435\u0442\u0430 \u0434\u043b\u044f \u043f\u043e\u0445\u0443\u0434\u0435\u043d\u0438\u044f' print string
In the console we get
D:\Python27\python.exe /test.py \u0434\u0438\u0435\u0442\u0430, \u0434\u0438\u0435\u0442\u0430 \u0434\u043b\u044f \u043f\u043e\u0445\u0443\u0434\u0435\u043d\u0438\u044f
If you do this
# coding: utf-8 string = u'\u0434\u0438\u0435\u0442\u0430, \u0434\u0438\u0435\u0442\u0430 \u0434\u043b\u044f \u043f\u043e\u0445\u0443\u0434\u0435\u043d\u0438\u044f' print string
\ u0435 \ u0442 \ u0430, \ u0434 \ u0438 \ u0435 \ u0442 \ u0430 \ u0434 \ u043b \ u044f \ u043f \ u043e \ u0445 \ u0443 \ u0434 \ u0435 \ u043d \ u0438 \ u044f'# coding: utf-8 string = u'\u0434\u0438\u0435\u0442\u0430, \u0434\u0438\u0435\u0442\u0430 \u0434\u043b\u044f \u043f\u043e\u0445\u0443\u0434\u0435\u043d\u0438\u044f' print string
then in the console we get the correct conclusion
диета, диета для похудения
But the fact is that I get the variable string from the outside, and I can not convert it in any way as in the second version.
That is, in the end I need a code of this type:
# coding: utf-8 string = string # здесь манипуляции по преобразованию строки из символов юникода в нормлаьный вид print string
type(string)
- modenprint('\u0434\u0438')
normal Russian text in: IDLE Windows, Windows Console, IDLE Ubuntu, Ubuntu Console. - ReinRausrepr(unicode_text)
. The parser language, in this case, nothing to do with. - drdaemanunicode-escape
:json.loads(r'"\u0434\u0438\u0435"')
- jfs