import psutil def show_process(): ‘‘‘列出所有当前正在运行的进程pid-name信息‘‘‘ for proc in psutil.process_iter(): try: pinfo = proc.as_dict(attrs=[‘pid‘, ‘name‘]) except psutil.NoSuchProcess: pass else: print(pinfo) if __name__ == ‘__main__‘: show_process() # 打印出当前运行的进程