繁体   English   中英

如何在 Python 中获取 CPU 温度? 假设我有 Windows 32 位

[英]How can I get CPU temperature in Python? Assuming that I have Windows 32-bits

我曾尝试使用sensors_temperatures()使用psutil库,但它给了我一个AttributeError。 这是我的代码:

import psutil
print(psutil.sensors_temperatures())

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-28-fbefe6006680> in <module>
----> 1 print(psutil.sensors_temperatures())

AttributeError: module 'psutil' has no attribute 'sensors_temperatures'

此外,当我使用help(psutil)检查时, psutil似乎不再存在函数sensors_temperatures() help(psutil)

先生,您可以使用简单的代码使用python查找CPU温度。 并且没有必要只使用“psutil”来查找温度。 您可以使用此处描述的 WMI 模块 + 打开硬件监视器 + 其 WMI 接口。

import wmi
w = wmi.WMI(namespace="root\OpenHardwareMonitor")
temperature_infos = w.Sensor()
for sensor in temperature_infos:
    if sensor.SensorType==u'Temperature':
        print(sensor.Name)
        print(sensor.Value)

# This is a simple code to find the temperature of the CPU using Python.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM