Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想创建一个基本上执行此操作的小脚本:
run program1.exe --> kill program1.exe after n seconds --> run program1.exe again.
我知道一些基本的 Python 并且会阅读这个,但我有点着急,只需要尽快完成。
如果有人有脚本/想法或者可以帮助我解决我需要打开并杀死 .exe 文件的语法,请......我也不介意其他语言的解决方案。如果这有点“请写我的代码”,我很抱歉,这不是我通常做的事情。
阅读subprocess 模块。
import subprocess, time p = subprocess.Popen(['program1.exe']) time.sleep(1) # Parameter is in seconds p.terminate() p.wait()