可能重复:
Run python script without DOS shell appearing
How do I hide the console when I use os.system() or subprocess.call()?
我需要制作一个Python2.2程序来关闭一个进程。问题是我不希望用户看到CMD窗口。有可能吗?
import os
os.system("taskkill /im injector* /f")
os.system("taskkill /im *injector /f")
答案 0 :(得分:0)
尝试使用子流程模块,样本为here
您需要指定shell=True
类似的东西:
subprocess.call("taskkill.exe /im injector* /f", shell=True)
不会显示控制台窗口。
别忘了
import subprocess