splitting string
Robert Brewer
fumanchu at amor.org
Thu Jul 8 11:31:34 EDT 2004
Laura McCord wrote:
> I want to split a filename string such as Y:\folder\directory\file
>
> it is stored like this in my python code:
> fname = self.filename
>
> How can I get rid of everything before the word 'file'?
>
> I had tried something like this:
> fname = self.filename
> s = fname.split("\")
> fname = s[-1]
>
> Any suggestions?
The line:
s = fname.split("\")
...should give you a SyntaxError; You can't end a string with a slash
like that. Try:
s = fname.split("\\")
Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org
More information about the Python-list
mailing list