我正在尝试使用 Popen 调用命令行。
命令行在shell中操作
cd C:\Program Files (x86)\Inventor
Inventor -exe -- no-gui -f C:\Users\Vince\Documents\Inventor\Inventor.iam
但是当我在程序中使用 Popen 尝试时
from subprocess import *
from os.path import expanduser
home = expanduser("~")
path = home + "\\Documents\\Inventor\\Inventor.iam"
cmd = "Inventor -exe -- no-gui -f " + path
Popen(cmd, cwd="C:\\Program Files (x86)\\Inventor")
它返回给我FileNotFoundError: [WinError 2]
所以我无法弄清楚文件路径出了什么问题。
最佳答案
在参数中添加 (shell =True)
关于python - 具有多个参数、变量和当前工作目录的命令行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31134128/