安装依赖
pip install psutil
代码
import psutil def check_if_process_running(process_name): ''' Check if there is any running process that contains the given name process_name. ''' # Iterate over the all the running process for proc in psutil.process_iter(): try: # Check if process name contains the given name string. if process_name.lower() in proc.name().lower(): return True except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): pass return False; # Check if "example.exe" process is running is_running = check_if_process_running('xxx.exe') print('xxx.exe is running: ' + str(is_running))
标签:exe,name,process,检测,psutil,running,Check From: https://www.cnblogs.com/uoky/p/18241747