環境:
Windows 10操作系統
python idle
原理:
調用windows系統自帶的命令task,該命令使用方式:
第一步、調用cmd命令行,顯示當前系統中所有進程;
Win+R->cmd->(input)tasklist
第二步、調用taskkill命令,關閉指定的進程;
taskkill [/S system [/U username [/P [password]]]]
{[/FI filter] [/PID processid] | /IM imagename} [/T] [/F]
常用調用方式為:
進程終止過程示例:
##假定關閉進程SougouCloud.exe
一、window10 cmd命令行中
C:\User\username\ tasklist ##顯示的列表中查看是否找到SougouCloud.exe C:\User\username\ taskkill /IM SougouCloud.exe /F
二、python idle中
>>>import os >>>print(os.popen('tasklist')) >>>os.system('taskkill /IM SougouCloud.exe /F')