Read utf-8 file

Peter Otten __peter__ at web.de
Mon Mar 18 11:37:05 CET 2013


moonhkt wrote:

> How to display
> e4b8ad for 中 in python ?

Python 2

>>> print u"中".encode("utf-8").encode("hex")
e4b8ad


Python 3

>>> print(binascii.b2a_hex("中".encode("utf-8")).decode("ascii"))
e4b8ad





More information about the Python-list mailing list