Changing Working Directory in Windows
pekka niiranen
krissepu at vip.fi
Mon Mar 11 09:47:49 EST 2002
You could try playing with pythonwin's commandline:
import os
>>> os.getcwd()
'E:\\Python22\\lib\\site-packages'
>>> os.chdir('..')
>>> os.getcwd()
'E:\\Python22\\lib'
>>> newpath = os.path.join(os.getcwd(), 'mydirectory', 'myfile.txt')
>>> print newpath
E:\Python22\lib\mydirectory\myfile.txt
-pekka-
nrk at cmcorp.com wrote:
>I'm brand new to Python. Can someone tell me how to change a working
>directory in a script on a Windows system?
>
>What does the pathname specification look like?
>Can I use an absolute path name when referring to a file?
>
>Thanks for any help you can give me.
>
>Norm Kashdan
>
More information about the Python-list
mailing list