Python OpenHardwareMonitor 和 WMI 获取 CPU 温度 [英] Python OpenHardwareMonitor and WMI getting cpu temps
问题描述
我正在做一个小项目来获取我的 Windows 机器上的 CPU 温度.我决定使用 wmi 模块,并在下面的问题链接上遇到了一段代码,它起初工作正常,但突然间它会停止打印结果,而且 OpenHardwareMonitor 似乎没有向 wmi 报告模块.
I am working on a small project to get the cpu temperature on my windows machine. I settled on using the wmi module and have come across a snippet of code on the question link below and it was working at first but all of a sudden it would stop printing out the results and it seems like OpenHardwareMonitor is not reporting back to the wmi module.
代码:
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)
预先感谢您的帮助.
推荐答案
我解决了这个问题,代码从 OpenHardwareMonitor 0.4.0 版升级到 0.4.0.3 版
I resolved the problem and the code started to work correctly by going from OpenHardwareMonitor version 0.4.0 to version 0.4.0.3
这篇关于Python OpenHardwareMonitor 和 WMI 获取 CPU 温度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!