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 0x03039

and print "0x%05X" % 12345 displays 0x03039

The Python docs state
The conversion will be zero padded for numeric values, when a 0 is used as
a flag between the % and the conversion type.

If you continue in the documentation right after 3 Conversion flags comes 4 Minimum field width


Bob Gailer
[EMAIL PROTECTED]
303 442 2625 home
720 938 2625 cell


_______________________________________________
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to