【发布时间】:2019-07-12 23:06:16
【问题描述】:
我正在尝试使用 Python 脚本来启动多个程序。我面临的问题是,虽然这些程序中的第一个程序在 shell 中按预期执行,但第二个程序永远不会执行。有没有办法启动第一个程序并且没有让子进程等待启动第二个程序?
我尝试使用 subprocess 模块中的 call 函数,让主程序等待 5 秒,然后启动第二个。
import subprocess
subprocess.call(['xxx', 'xxxxxx', 'xxxxxxxx', 'shell=True'])
time.sleep(5)
subprocess.call(['xxx', '-x', 'xxxxxx'])
我希望程序在 shell 中启动这些程序中的每一个,但只启动第一个程序。
【问题讨论】:
标签: python-3.x subprocess