char string 2 hex string

Antonio Chay antonio.chay at gmail.com
Thu Jan 31 17:05:00 EST 2008


Hello!

I need to transform a string from a file into a hexadecimal
representation, for example:

"AAA" should be "414141"

With perl I do this with:

unpack("H*","AAA")

And with python I got this:

"".join([str(hex(ord(x)))[2:] for x in "AAA"])

But seems a little "weird" for me.

Is there another way?
Thanks in advance!



More information about the Python-list mailing list