简体   繁体   中英

Decode a hex string into Chinese characters

I have a hex code: %E7%B5%99. I want to convert it into Chinese characters.

print ("%E7%B5%99".decode('utf-8'))

This doesn't seem to work.

It should give the answer: 絙

You need to "unquote" the percent encoded string first. Then decode from UTF8:

>>> s = "%E7%B5%99"
>>> print urllib.unquote(s).decode('utf8')
絙

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM