从Python查询CPU ID?

时间:2010-06-16 19:50:31

标签: python windows cpu

如何使用py2.6,Windows OS找到处理器ID?

我知道有pycpuid,但我无法在2.6下编译。

4 个答案:

答案 0 :(得分:5)

您是否尝试过wmi

Here's a solution

>>> import wmi
>>> c = wmi.WMI()
>>> for s in c.Win32_Processor():
    print s



instance of Win32_Processor
{
    AddressWidth = 64;
    Architecture = 9;
    Availability = 3;
    Caption = "Intel64 Family 6 Model 26 Stepping 5";
    CpuStatus = 1;
    CreationClassName = "Win32_Processor";
    CurrentClockSpeed = 3068;
    DataWidth = 64;
    Description = "Intel64 Family 6 Model 26 Stepping 5";
    DeviceID = "CPU0";
    ExtClock = 133;
    Family = 1;
    L2CacheSize = 1024;
    L3CacheSize = 8192;
    L3CacheSpeed = 0;
    Level = 6;
    LoadPercentage = 3;
    Manufacturer = "GenuineIntel";
    MaxClockSpeed = 3068;
    Name = "Intel(R) Core(TM) i7 CPU         950  @ 3.07GHz";
    NumberOfCores = 4;
    NumberOfLogicalProcessors = 8;
    PowerManagementSupported = FALSE;
    ProcessorId = "BFEBFBFF000106A5";
    ProcessorType = 3;
    Revision = 6661;
    Role = "CPU";
    SocketDesignation = "CPU 1";
    Status = "OK";
    StatusInfo = 3;
    SystemCreationClassName = "Win32_ComputerSystem";
    SystemName = "RYAN-PC";
    UpgradeMethod = 1;
    Version = "";
    VoltageCaps = 0;
};

答案 1 :(得分:2)

我发现{-3}}命令在Windows-XP上始终可用,并使用subprocess.Popen来运行它,而不是要求我的用户安装任何特殊的Python包。

C:\>wmic cpu get ProcessorId /format:csv

Node,ProcessorId
E100325,BFEBFBFF00000F43
E100325,BFEBFBFF00000F43

答案 2 :(得分:1)

您可以从WMI获取CPU ID。 VBScript Sample here 您可以使用Python中的WMI 结合这两种资源,我认为你可以弄清楚其余的。

答案 3 :(得分:0)

似乎有两个具有该名称的项目。你试过两个吗?