[Tutor] More confusion on conversion

Vicki Stanfield vicki at thepenguin.org
Thu Oct 30 13:19:20 EST 2003


Okay, don't ask me why because the answer I got was "for historical
reasons", but I have to take the length of something (a decimal value) and
convert it to its hexadecimal equivalent and then convert that value to
its hexadecimal equivalent padded to 2 places. The result is something
like this:

length = 10
convert 10 to A
convert A to 0x41
padded version = 0x30 0x41

When I try to convert the decimal 10 using either binascii.hexlify, I am
told that it wants a single value instead of the two digit 10. How does
one convert a 10 (decimal value) to its hex equivalent? I don't want the
hex equivalent of 1 followed by the hex equivalent of 0. The example above
is exactly what I must achieve.

--vicki



More information about the Tutor mailing list