I would like to display unicode characters without using print
for example :
>>> print 'é'
é
The unicode is displayed perfectly but when I try to display without print it gives me unwanted results :
>>> 'é'
'\xc3\xa9'
And the expected result is 'é'
EDIT
The reason why I need this feature is, I m writing a scraper with scrapy framework, and I m crawling a website with unicode charachters, when I start crawling the log display something like this :
\u06a9\u06cc\u0644\u0648 \u0645\u062a\u0631 \u0628\u0631 \u0633\u0627\u0639\u062a\r\n\r\n
I've tried to use unicode
built-in function, and I've added the header
# -*- coding: utf-8 -*-
But without any results
I'm not sure why you want to do this, but print
statement converts objects given certain string conversion rules. You're seeing the value through conversion.
The expression is the raw return when you're experiencing the unicode.
https://docs.python.org/2/reference/simple_stmts.html#grammar-token-print_stmt
Python3可能是您的解决方案,此版本支持UTF-8作为默认字符串编码。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.