我想知道是否可以执行此命令
cmd = "gnome-terminal -e 'python /path/to/file.py'"
p = subprocess.Popen(cmd,shell=True)
但是shell = False
我试图运行此命令
p = subprocess.Popen(["gnome-terminal","-e","python","/path/to/file.py"],shell = False)
但它不起作用:
谢谢!
答案 0 :(得分:2)
因为您将命令传递给gnome-terminal
,而不是python
。
p = subprocess.Popen(["gnome-terminal","-e","python /path/to/file.py"],shell = False)