当前位置:编程学习 > python >>

python下wmi模块介绍之三:得到进程和PID

今天继续介绍python下面的wmi这个模块的功能,下面介绍利用wmi模块得到本机运行的进程和进程的ID号,下面看下代码:

 #-*- encoding: utf-8 -*-  
 
Created on 2011-3-1 
 
@author: hack7th 
 
import wmi  
import time  
c = wmi.WMI()  
print ("下面显示的是本机的进程名和ID号")  
print "PID   &   Image Name " 
for process in c.Win32_Process():  
    print str(process.ProcessId) + "  &  " + process.Name 

#-*- encoding: utf-8 -*-

Created on 2011-3-1

@author: hack7th

import wmi
import time
c = wmi.WMI()
print ("下面显示的是本机的进程名和ID号")
print "PID   &   Image Name "
for process in c.Win32_Process():
    print str(process.ProcessId) + "  &  " + process.Name

补充:Web开发 , Python ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,