[Tutor] padding frames
alan.gauld at blueyonder.co.uk
Tue Jan 13 03:54:59 EST 2004
> x = ['DSCN-2.JPG', 'DSCN-11.jpg', 'DSCN-101.JPG',
> Problem 1:
> How do I go about putting the files into a list?
Try the glob module.
> even need to put the files into a list? After all, I
> just want to change their names. Do the files need to
> be opened?
No, just use the names.
> Problem 2:
> How do I isolate the portion of the file name that I
Try using the split() method of strings. split by '-'
to get the N.JPG bit then split that by '.' to get the
N by itself.
zfill N then join the three bits together again.
Author of the Learn to Program web tutor
More information about the Tutor