我想使用 python cd 到另一个目录,我想在运行的 shell 上执行此命令以导航到该目录。
command = 'cd ../../../'
os.popen(command)
这应该将我的 shell 导航到新目录
最佳答案
import os
os.chdir('/path/to/dir')
os.chdir 的文档是 here .
关于python - 如何使用 python 进行 shell 导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14541105/