import psutil
# 判断是否存在进程id为pid的进程
bool = psutil.pid_exists(pid: int)
# 获取进程id为pid的进程
pro = psutil.Process(pid: int)
# 获取进程名并改为小写
s = pro.name().lower()
# 杀死进程
pro.terminate()
# 获取当前所有进程id和进程名
l = psutil.pids()
print(l)
for each in l:
print("pid:{}, name:{}".format(each, psutil.Process(each).name()))