简体   繁体   中英

How to convert a string into ASCII?

How can I convert a string, say "HELLO" , into something like this?

As ASCII string: "72_69_76_76_79" .

I tried [ord(c) for c in string] , but it returns a list.

I want the result in the form of string

你可以使用这个:

"_".join([str(ord(c)) for c in "HELLO"])

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