char string 2 hex string
Jared Grubb
jared.grubb at gmail.com
Thu Jan 31 22:10:02 EST 2008
You could also do:
"".join(['%02x' % ord(c) for c in 'AAA'])
On 31 Jan 2008, at 14:09, Paul Rubin wrote:
Antonio Chay <antonio.chay at gmail.com> writes:
"AAA" should be "414141"
'AAA'.encode('hex')
--
http://mail.python.org/mailman/listinfo/python-list
On 31 Jan 2008, at 14:05, Antonio Chay wrote:
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!
--
http://mail.python.org/mailman/listinfo/python-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080131/06c14272/attachment-0001.html>
More information about the Python-list
mailing list