[Tutor] renaming files within a directory
alan.gauld at btinternet.com
Mon Jul 27 11:22:57 CEST 2009
<davidwilson at Safe-mail.net> wrote
> The problem is that for example the file Flag_of_the_United_States.svg
> when I use the strip('.svg') it is returned as Flag_of_the_United_State
Thats because strip removes all of the characters in the given string.
You would probably be better removing the extension using the
> Also, How do I remove 'Flag_of', 'Flag_of_the_'
You could try replacing with a null string. Do the second one first
followed by the first if necessary, using the string.replace() method.
Author of the Learn to Program web site
More information about the Tutor