最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

python使用wmi模块获取windows下的系统信息监控系统

来源:动视网 责编:小采 时间:2020-11-27 14:34:52
文档

python使用wmi模块获取windows下的系统信息监控系统

python使用wmi模块获取windows下的系统信息监控系统:Python用WMI模块获取Windows系统的硬件信息:硬盘分区、使用情况,内存大小,CPU型号,当前运行的进程,自启动程序及位置,系统的版本等信息。 本文实例讲述了python使用wmi模块获取windows下的系统信息 监控系统 #!/usr/bin/env pyth
推荐度:
导读python使用wmi模块获取windows下的系统信息监控系统:Python用WMI模块获取Windows系统的硬件信息:硬盘分区、使用情况,内存大小,CPU型号,当前运行的进程,自启动程序及位置,系统的版本等信息。 本文实例讲述了python使用wmi模块获取windows下的系统信息 监控系统 #!/usr/bin/env pyth


Python用WMI模块获取Windows系统的硬件信息:硬盘分区、使用情况,内存大小,CPU型号,当前运行的进程,自启动程序及位置,系统的版本等信息。

本文实例讲述了python使用wmi模块获取windows下的系统信息 监控系统

 #!/usr/bin/env python 
 # -*- coding: utf- -*- 
 #http://www.cnblogs.com/liu-ke/
 import wmi 
 import os 
 import sys 
 import platform 
 import time 
 def sys_version(): 
 c = wmi.WMI () 
 #获取操作系统版本 
 for sys in c.Win_OperatingSystem(): 
 print "Version:%s" % sys.Caption.encode("UTF"),"Vernum:%s" % sys.BuildNumber 
 print sys.OSArchitecture.encode("UTF")#系统是位还是位的 
 print sys.NumberOfProcesses #当前系统运行的进程总数
 def cpu_mem(): 
 c = wmi.WMI () 
 #CPU类型和内存 
 for processor in c.Win_Processor(): 
 #print "Processor ID: %s" % processor.DeviceID 
 print "Process Name: %s" % processor.Name.strip() 
 for Memory in c.Win_PhysicalMemory(): 
 print "Memory Capacity: %.fMB" %(int(Memory.Capacity)/) 
 def disk(): 
 c = wmi.WMI () 
 #获取硬盘分区 
 for physical_disk in c.Win_DiskDrive (): 
 for partition in physical_disk.associators ("Win_DiskDriveToDiskPartition"): 
 for logical_disk in partition.associators ("Win_LogicalDiskToPartition"): 
 print physical_disk.Caption.encode("UTF"), partition.Caption.encode("UTF"), logical_disk.Caption 
 #获取硬盘使用百分情况 
 for disk in c.Win_LogicalDisk (DriveType=): 
 print disk.Caption, "%.f%% free" % (. * long (disk.FreeSpace) / long (disk.Size)) 
 def network(): 
 c = wmi.WMI () 
 #获取MAC和IP地址 
 for interface in c.Win_NetworkAdapterConfiguration (IPEnabled=): 
 print "MAC: %s" % interface.MACAddress 
 for ip_address in interface.IPAddress: 
 print "ip_add: %s" % ip_address 
 print 
 def main(): 
 sys_version() 
 cpu_mem() 
 #disk() 
 #network() 
 if __name__ == '__main__': 
 main() 
 print platform.system() 
 print platform.release() 
 print platform.version() 
 print platform.platform() 
 print platform.machine()

以上内容是关于python使用wmi模块获取windows下的系统信息 监控系统的相关知识,希望对大家有所帮助。

文档

python使用wmi模块获取windows下的系统信息监控系统

python使用wmi模块获取windows下的系统信息监控系统:Python用WMI模块获取Windows系统的硬件信息:硬盘分区、使用情况,内存大小,CPU型号,当前运行的进程,自启动程序及位置,系统的版本等信息。 本文实例讲述了python使用wmi模块获取windows下的系统信息 监控系统 #!/usr/bin/env pyth
推荐度:
标签: 信息 系统 python
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top