import os
# 获取当前工作目录
print("当前工作目录:", os.getcwd())
# 更改工作目录到指定路径
os.chdir('/path/to/directory')
# 验证工作目录是否已更改
print("更改后的工作目录:", os.getcwd())
os.getcwd()
: 获取当前工作目录的路径。os.chdir('/path/to/directory')
: 将当前工作目录更改为指定的路径 /path/to/directory
。你需要将 /path/to/directory
替换为你想要更改到的实际目录路径。os.getcwd()
来验证工作目录是否已成功更改。如果你在 Windows 系统上运行,路径格式应为类似 'C:\\Users\\Username\\Documents'
。
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站