Newbie asks, how to get rid of the last four characters of a string?
Max M
maxm at mxm.dk
Wed Jan 22 09:33:16 EST 2003
More information about the Python-list mailing list
Wed Jan 22 09:33:16 EST 2003
- Previous message (by thread): Newbie asks, how to get rid of the last four characters of a string?
- Next message (by thread): Newbie asks, how to get rid of the last four characters of a string?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Christopher Culver wrote: > I'm somewhat new to Python and have run into this problem: I have a script > whose first argument takes a MS Word file, which would end with .doc. I > want to remove ".doc" and have just the file name without extension. Now, > I know I can do this with regular expressions, but is there a function > that can be used to chomp off the last four characters without having to > import the re module? You can just use a slice. 'filename.doc'[:-4] >>> filename regards Max M -- hilsen/regards Max M http://www.futureport.dk/ Fremtiden, videnskab, skeptiscisme og transhumanisme
- Previous message (by thread): Newbie asks, how to get rid of the last four characters of a string?
- Next message (by thread): Newbie asks, how to get rid of the last four characters of a string?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list