0

我需要使用 python 脚本启动一个 exe,但我也需要使用相同的脚本来杀死它

一个开始的想法是:

process = magicCommand( 'theExe.exe' ) #invoke exe

kill = 'no'
while kill == 'no':
    kill = raw_input()

otherMagicCommand( process ) #kill

编辑

这对我有用

process = subprocess.Popen( 'theExe.exe' ) #invoke exe

kill = 'no'
while kill == 'no':
    kill = raw_input()

process.kill() #kill
4

1 回答 1

2

Python子流程模块和一些很好的例子和解释

于 2011-08-15T17:19:05.717 回答