简体   繁体   中英

How to convert unicode string to decimal number in python?

Example i have this text string:

string = 'Vui lòng giúp đỡ tôi'

How to convert it to integer to use with unichr() ?

Example result:

\u...\u...

You don't need to, if you decode it.

>>> 'Vui lòng giúp đỡ tôi'
'Vui l\xc3\xb2ng gi\xc3\xbap \xc4\x91\xe1\xbb\xa1 t\xc3\xb4i'
>>> 'Vui lòng giúp đỡ tôi'.decode('utf-8')
u'Vui l\xf2ng gi\xfap \u0111\u1ee1 t\xf4i'
>>> print 'Vui lòng giúp đỡ tôi'.decode('utf-8')
Vui lòng giúp đỡ tôi

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