在Python中,你可以使用os模块的chdir()函数来更改当前工作目录
import os
# 使用绝对路径更改当前工作目录
abs_path = "/path/to/your/directory"
os.chdir(abs_path)
# 打印当前工作目录以确认更改
print("Current working directory:", os.getcwd())
在这个例子中,将/path/to/your/directory替换为你想要设置为当前工作目录的绝对路径。os.chdir()函数会更改当前工作目录,然后os.getcwd()函数会返回当前工作目录的路径。