如何在 Python 中获取处理器名称? [英] How to get the processor name in Python?

查看:29
本文介绍了如何在 Python 中获取处理器名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Windows 笔记本电脑上使用 Python 中的平台模块,我得到以下输出

Using the platform module in Python on my Windows laptop, I get the following output

import platform
platform.processor()

'Intel64 Family 6 Model 58 Stepping 9, GenuineIntel'

但是,如果我查看 Windows 系统信息,我会被告知我的处理器是 Intel Core i5-3317U CPU,频率为 1.70Ghz.如何让 Python 以这种格式返回处理器信息?

If I look at the Windows System Information, however, I am told that my processor is an Intel Core i5-3317U CPU at 1.70Ghz. How can I get Python to return processor information in this format?

推荐答案

通过 pywin32 你可以:

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

Intel(R) Xeon(R) CPU W3550 @ 3.07GHz

您还可以通过这种方式获取有关 CPU 的各种信息.请参阅此 MSDN 文章

You can also get all sorts of info on the CPUs this way. See this MSDN article

这篇关于如何在 Python 中获取处理器名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆