RE Despair - help required
Marc Boeren
m.boeren at guidance.nl
Thu Aug 25 10:15:45 EDT 2005
Hi,
> Don't think it will do much good. I need to get them from a file and
> extract the last folder in the path. For example:
> if I get "c:\dos\util"
> I want to extract the string "\util"
Still, os.path is your friend:
import os
filepath = r'C:\dos\util'
base, last = os.path.split(filepath)
print base # 'C:\dos'
print last # 'util'
print os.sep+last # '\util'
Don't forget to read
> > http://docs.python.org/lib/module-os.path.html
for some more info!
Regards, Mc!
More information about the Python-list
mailing list