[plug] [OT] Adding leading zeros in python
rpowersau at gmail.com
rpowersau at gmail.com
Tue Dec 21 16:47:09 WST 2004
Hi,
I'm trying to iterate through a range from 1 to 20 and get a file and
save it locally. I want the local files to be named file 01, file02,
...... file 20.
I'm very newbie with python and this is what I'm using:
>>> for i in range(1,21):
... localf = 'file%2s' %i
... print localf
...
file 1
file 2
file 3
file 4
file 5
file 6
file 7
file 8
file 9
file10
file11
file12
file13
file14
file15
file16
file17
file18
file19
file20
Close, but no cigar. ;)
Anybody know what I have to do to get zero instead of a space in
those first 9 filenames? It must be simple but I can't get it to
happen.
I've been googling, but haven't hit it yet. :)
Thanks.
--
Regards,
Russ
More information about the plug
mailing list