How to get the processor name in Python?

Wal*_*mly 4 python windows

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

import platform
platform.processor()
Run Code Online (Sandbox Code Playgroud)

'Intel64 Family 6 Model 58 Stepping 9, GenuineIntel'

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?

ser*_*inc 6

如果您可以使用库(从Gettingprocessor information in Python复制答案)

您可以使用cpuinfo

安装为pip install py-cpuinfo

从命令行使用:python -m cpuinfo

代码:

import cpuinfo
cpuinfo.get_cpu_info()['brand_raw']
Run Code Online (Sandbox Code Playgroud)


Dav*_*vid 5

With some com interface through pywin32 you can:

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
Run Code Online (Sandbox Code Playgroud)

The result on my machine:

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

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