subprocess.Popen正是您想要的。
from subprocess import Popenp = Popen(['watch', 'ls']) # something long running# ... do other stuff while subprocess is runningp.terminate()
(编辑以完成评论的答案)
Popen实例可以执行其他各种操作,例如可以
poll()查看它是否仍在运行,还可以
communicate()使用它在stdin上发送数据,并等待其终止。



