首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在Python中获取CPU温度?假设我有32位的Windows

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

Stack Overflow用户
提问于 2020-03-15 19:16:09
回答 1查看 2.9K关注 0票数 0

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

代码语言:javascript
复制
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)检查函数sensors_temperatures()时,它似乎不再存在于psutil

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-15 23:17:15

先生,您可以使用简单的代码使用python来查找CPU温度。而且没有必要只使用'psutil‘来计算温度。您可以使用此处所述的WMI模块+ Open Hardware Monitor +其WMI接口。

代码语言:javascript
复制
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.
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60692260

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档