Reputation: 65
How can I convert a string, say "HELLO", into something like this?
"HELLO"
As ASCII string: "72_69_76_76_79".
"72_69_76_76_79"
I tried [ord(c) for c in string], but it returns a list.
[ord(c) for c in string]
I want the result in the form of string
Upvotes: 0
Views: 59
Reputation: 1726
you can use this:
"_".join([str(ord(c)) for c in "HELLO"])
Upvotes: 3