终止任务程序
#!/usr/bin/env python3#coding:utf-8
import os
import re
t_kill = 'taskkill /f /pid {}'
t_list = 'tasklist'
pgmlist = ['QQBrowser.exe','calc','notepad++'] #待终止程序名列表
pgmlen = len(pgmlist)
klist = []
for i in os.popen(t_list):
print(i,end='')#打印运行程序列表
for i in os.popen(t_list):
for n in range(pgmlen):
if i.find(pgmlist) == 0:#查找相应项,并添加到klist列表中
klist.append( for n in range(2)]) #
break
# print(klist)
for i in klist:
err = os.system(t_kill.format(i)) #taskkill /f /pid 666
if err != 0:
print(t_list.format(i),'Fail!')
{:10_266:}不会 调用终端命令
页:
[1]