[Tutor] simply moving files]]
Alan Gauld
alan.gauld at btinternet.com
Wed May 13 09:58:56 CEST 2009
"David" <david at abbottdavid.com> wrote
> Forwarded to the list, I would also like to understand the forward slash;
> os.system("mv %s/%s %s" % (src, fnames, dst))
The slash separates the file path, src, from the filename.
Thus if src is /foo/bar/baz
and fnames is spam
then %s/%s becomes
/foo/bar/baz/spam
Another way of doing the same thing would be with join:
'/'.join([src,fnames])
or for platform independance:
os.sep.join([src,fnames])
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list