终端执行和popen之间的区别

时间:2016-04-28 21:13:48

标签: python python-2.7 terminal subprocess popen

在我的ubuntu终端中键入命令会识别我的命令中的参数t

/home/daniel/Downloads/SALOME-7.6.0-UB14.04/salome start -t

通过Popen在python中启动相同进程有什么区别?

command ='/home/daniel/Downloads/SALOME-7.6.0-UB14.04/salome'
commandargs= 'start -t'

import subprocess
subprocess.Popen([command, commandargs], shell=True).wait()

我的参数代表终端模式,但通过python运行我的应用程序(salome)Popen打开GUI。

1 个答案:

答案 0 :(得分:0)

请参阅:https://docs.python.org/3.5/library/subprocess.html#subprocess.Popen

args should be a sequence of program arguments or else a single string. 


另见:https://stackoverflow.com/a/11309864/2776376

subprocess.Popen([command, commandargs.split(' ')], shell=True).wait()

或者你可以做,虽然不太推荐:

subprocess.Popen(command + commandargs, shell=True).wait()

应该做的伎俩