Stayvoid wrote:
Hey folks!

What's the difference between these commands?

print "%02d" % (12)

print "%d" % (12)

I know that "d" stands for decimal. What does "02" mean?

"0" means to use leading zeroes; "2" means to use 2 digits. Here's a better example:


py> "%05d" % 12
'00012'


More information here:

http://docs.python.org/library/stdtypes.html#string-formatting-operations

--
Steven
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to