在我的Windows笔记本电脑上使用Python中的平台模块,我得到以下输出
import platform platform.processor()
'Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
”
但是,如果我查看Windows系统信息,则会被告知我的处理器是1.70Ghz的Intel Core i5-3317U CPU。 我怎样才能让Python以这种格式返回处理器信息?
通过pywin32的一些COM接口,你可以:
def get_cpu_type(): from win32com.client import GetObject root_winmgmts = GetObject("winmgmts:root\cimv2") cpus = root_winmgmts.ExecQuery("Select * from Win32_Processor") return cpus[0].Name
我的机器上的结果:
Intel(R)Xeon(R)CPU W3550 @ 3.07GHz
您也可以通过这种方式获取CPU上的各种信息。 看到这个MSDN文章