Printing a hex character and prefixing it correctly
Chris Rebert
clp2 at rebertia.com
Fri May 15 12:43:57 EDT 2009
On Fri, May 15, 2009 at 9:15 AM, <xamalek at yahoo.com> wrote:
> If I have an integer k, for instance;
>
> k = 32 // BASE 10
>
> How do I get print to print it out in HEX and PREFIXED with 0x? What
> is the PROPER WAY?
>
> This does not work:
>
> print "This is hex 32: ", int(k, 16)
print "This is hex 32:", hex(k)
print int("0xA", 16) #==> 10
I would recommend you read the tutorial and/or library reference if
you haven't already.
Cheers,
Chris
--
http://blog.rebertia.com
More information about the Python-list
mailing list