On Wed, 15 Dec 2004 20:40:40 -0500, R. Alan Monroe
<[EMAIL PROTECTED]> wrote:
> > print "0x%0X" % 12345
>
> > displays
> > 0x3039
>
> > instead of 0x03039
>
>
> >>> "%05x" % (12345,)
> '03039'
>
> >>> "0x%05x" % (12345,)
> '0x03039'
>
> ___
> Tutor
At 06:47 PM 12/15/2004, Tony Cappellini wrote:
I'm trying to get Python to automatically print a leading 0 for hex
numbers, but it only seems to work for for decimal numbers.
Oh? print "%0d" % 12345 gives me 12345 - no leading 0
print "0x%0X" % 12345
displays 0x3039
which it should
instead of 0x030
On Wed, 15 Dec 2004 17:47:58 -0800 (PST), Tony Cappellini
<[EMAIL PROTECTED]> wrote:
>
> I'm trying to get Python to automatically print a leading 0 for hex
> numbers, but it only
> seems to work for for decimal numbers.
>
> print "0x%0X" % 12345
>
> displays
> 0x3039
>
> instead of 0x03039
>
> print "0x%0X" % 12345
> displays
> 0x3039
> instead of 0x03039
>>> "%05x" % (12345,)
'03039'
>>> "0x%05x" % (12345,)
'0x03039'
___
Tutor maillist - [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor
I'm trying to get Python to automatically print a leading 0 for hex
numbers, but it only
seems to work for for decimal numbers.
print "0x%0X" % 12345
displays
0x3039
instead of 0x03039
The Python docs state
The conversion will be zero padded for numeric values, when a 0 is used as
a flag betw