zero padded string

Max Møller Rasmussen maxm at normik.dk
Mon Aug 27 05:13:11 EDT 2001


> From: Hans Nowak [mailto:hnowak at cuci.nl]

> Do you mean something like this?
> 
> >>> '%09d' % 42
> '000000042'

I meant exactly like that :-)


> Or, if all strings are actually numbers, you can convert them 
> to ints and sort 
> them:
> 
> >>> z = ["4", "42", "4100", "411"]
> >>> z = map(int, z)
> >>> z.sort()
> >>> z
> [4, 42, 411, 4100]

Unfortunately that is not aplicable in this case.

Thanks Max M




More information about the Python-list mailing list