[Tutor] How to Split a String
Alan Gauld
alan.gauld at btinternet.com
Sat Aug 8 21:42:41 CEST 2009
"Paras K." <paras80 at gmail.com> wrote
> lotusnotesmaildir = glob.glob('C:\Documents and
> Settings/pkinariwala/Local
> Settings/Application Data/lotus/notes/data/'+'*mail*/')
You don't need the plus.
lotusnotesmaildir = glob.glob('C:\Documents and Settings/pkinariwala/Local
Settings/Application Data/lotus/notes/data/'*mail*/')
> That returns: ['C:\\Documents and Settings/pkinariwala/Local
> Settings/Application Data/lotus/notes/data\\mail02\\']
Are you sure it isn't
['C:\\Documents and Settings\\pkinariwala\\Local
Settings\\Application Data/lotus\\notes\\data\\mail02\\']
> What I am trying to do is split the mail folder, in this case it would be
> mail02, but not all users would have that same mail folder.
If so then you can use
var[0].split('\\')[-1]
to get the last item.
You might also find the path manipulation and basename functions
useful for mamnipulating paths. Especially if you need to do it on
multiple different computers/OS. These are in the os/os.path
module family.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list