zero padded string
Max Møller Rasmussen
maxm at normik.dk
Thu Aug 23 10:29:07 EDT 2001
What is the simplest way to make a zero padded string usable for
alphabetically sorting?
This does it.
number="42"
print (8*'0')[:-len(number)] + number
>> 00000042
But my guess is that there is a builtin c-formatting that does it shorter.
I'll be damned if I know what it is!
There will allways be the same number of zeroes.
regards Max
- Nørgård Mikkelsen a/s -
www.normik.dk - Vandværksvej 18 - DK 5000 Odense C
Tlf (+45) 66 14 14 80 - Fax (+45) 66 14 19 43
Max M - Direkte (+45) 63 14 47 15
More information about the Python-list
mailing list