wmi模块 / wmi Module
WMI (Windows Management Instrumentation) 模块可用于获取 Windows 内部信息。该模块需要 win32com 的支持,环境安装如下,
pip install wmi
pip install pypiwin32
模块信息
WMI() 类
类实例化:w = wmi.WMI()
类的功能: 用于生成 WMI 的实例
传入参数: 无
返回参数: w
Win32_Processor() 方法
函数调用: processorList = w.Win32_Processor()
函数功能: 用于获取处理器信息对象,并存以列表形式
传入参数: 无
返回参数: processorList
processorList: list类型,list中每个元素均为一个含cpu信息的object
cpu object通过object.name调用,所含信息包括:
instance of Win32_Processor { AddressWidth = 64; Architecture = 9; Availability = 3; Caption = "Intel64 Family 6 Model 78 Stepping 3"; CpuStatus = 1; CreationClassName = "Win32_Processor"; CurrentClockSpeed = 2376; CurrentVoltage = 9; DataWidth = 64; Description = "Intel64 Family 6 Model 78 Stepping 3"; DeviceID = "CPU0"; ExtClock = 100; Family = 205; L2CacheSize = 512; L3CacheSize = 3072; L3CacheSpeed = 0; Level = 6; LoadPercentage = 29; Manufacturer = "GenuineIntel"; MaxClockSpeed = 2401; Name = "Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz"; NumberOfCores = 2; NumberOfLogicalProcessors = 4; PowerManagementSupported = FALSE; ProcessorId = "BFEBFBFF000406E3"; ProcessorType = 3; Revision = 19971; Role = "CPU"; SocketDesignation = "U3E1"; Status = "OK"; StatusInfo = 3; SystemCreationClassName = "Win32_ComputerSystem"; SystemName = "CN00208511"; UpgradeMethod = 1; Version = ""; };