一、上代码

import psutil

for proc in psutil.process_iter():
try:
pinfo = proc.as_dict(attrs=['pid', 'name'])
except psutil.NoSuchProcess:
pass
else:
print(pinfo)

二、效果:

Python取得系统进程列表-LMLPHP

05-11 20:13