Getting processor information in Python

后端 未结 10 2006
一向
一向 2020-11-29 04:20

Using Python is there any way to find out the processor information... (I need the name)

I need the name of the processor that the interpreter is running on. I check

10条回答
  •  甜味超标
    2020-11-29 05:09

    Working code (let me know if this doesn't work for you):

    import platform, subprocess
    
    def get_processor_info():
        if platform.system() == "Windows":
            return platform.processor()
        elif platform.system() == "Darwin":
            return subprocess.check_output(['/usr/sbin/sysctl', "-n", "machdep.cpu.brand_string"]).strip()
        elif platform.system() == "Linux":
            command = "cat /proc/cpuinfo"
            return subprocess.check_output(command, shell=True).strip()
        return ""
    

提交回复
热议问题