如何设置当前工作目录?

2024-05-23 00:44:40 发布

您现在位置:Python中文网/ 问答频道 /正文

如何在Python中设置当前工作目录?


Tags: 目录
3条回答

尝试^{}

os.chdir(path)

        Change the current working directory to path. Availability: Unix, Windows.

也许这就是你想要的:

import os
os.chdir(default_path)
import os
print os.getcwd()  # Prints the current working directory

要设置工作目录:

os.chdir('c:\\Users\\uname\\desktop\\python')  # Provide the new path here

相关问题 更多 >

    热门问题