How to convert a number to hex number?
Aaron Bingham
bingham at cenix-bioscience.com
Tue Nov 8 04:59:32 EST 2005
Hako wrote:
>I try this command:
>
>
>>>>import string
>>>>string.atoi('78',16)
>>>>
>>>>
>120
>this is 120 not 4E.
>
>Someone can tell me how to convert a decimal number to hex number? Can
>print A, B, C,DEF.
>
>
To print the hexidecimal string representation of an integer, n, use
print hex(n)
or
print "%x" % n
Regards,
Aaron Bingham
More information about the Python-list
mailing list