Python在另一个DOS.exe命令中执行一个命令

2024-10-05 19:28:31 发布

您现在位置:Python中文网/ 问答频道 /正文

在python中,我知道如何使用subprocess.Popen启动命令

process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

我要做的是:1)调用一个可执行的.exe命令,2)然后在该命令运行之后调用另一个命令。 所以当我这样做的时候:

process = subprocess.Popen("C:\Automation\helpFiles\topCmd.exe", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

once that is running I need to run another command i.e state

我该怎么做


Tags: 命令cmdtruestderrstdoutshellprocessexe