如何设置当前工作目录?
如何在Python中设置当前工作目录?
4 个回答
70
import os
print os.getcwd() # Prints the current working directory
要设置工作目录:
os.chdir('c:\\Users\\uname\\desktop\\python') # Provide the new path here
153
也许这就是你在找的东西:
import os
os.chdir(default_path)
1015
试试 os.chdir
import os os.chdir(path)
把当前的工作目录改成你指定的路径。这个功能在Unix和Windows系统上都可以用。