[plug] [OT] Adding leading zeros in python
James Devenish
devenish at guild.uwa.edu.au
Tue Dec 21 19:41:51 WST 2004
In message <476484250412210332750a445d at mail.gmail.com>
on Tue, Dec 21, 2004 at 07:32:11PM +0800, rpowersau at gmail.com wrote:
[... '%02d' vs '%.2d' ...]
> How do they differ?
http://docs.python.org/lib/typesseq-strings.html
Summary:
- '02' means "pad numeric values with zeros and use a minimum field
width of 2".
- '.2' means "use two digits of precision".
For integers, there is no difference between these two (i.e. it appears
that '.2' is degenerate). For other numbers, the codes are distinct
(e.g. '.2' refers to the precision after the decimal point. '02'
refers to the number of characters *overall*).
More information about the plug
mailing list