python检测进程是否存在
# 使用win32com来判断进程是否存在 import win32com.client def proc_exist(process_name): is_exist = False wmi = win32com.client.GetObject('winmgmts:') processCodeCov = wmi.ExecQuery('select * from Win32_Process where name=\"%s\"' %(process_name)) if len(processCodeCov) > 0: is_exist = True return is_exist if proc_exist('chrome.exe'): print('chrome.exe is running') else: print('no such process...')