import clr
import time
#獲取cpu溫度
clr.AddReference(r'D:\temp\OpenHardwareMonitor\OpenHardwareMonitorLib.dll') //你的.dll文件地址
from OpenHardwareMonitor.Hardware import Computer
c = Computer()
c.CPUEnabled = True # get the Info about CPU
c.GPUEnabled = True # get the Info about GPU
c.Open()
while True:
#c.Hardware[0].Update() # 更新傳感器數(shù)據(jù)
for a in range(0, len(c.Hardware[0].Sensors)):
if "/temperature" in str(c.Hardware[0].Sensors[a].Identifier):
print(f"cpu溫度:{c.Hardware[0].Sensors[a].get_Value()}", flush=True)
c.Hardware[0].Update()
break
time.sleep(1) //延遲一秒
要用管理員模式啟動(dòng)pycharm文章來源:http://www.zghlxwxcb.cn/news/detail-636611.html
https: // openhardwaremonitor.org 獲取.dll文件文章來源地址http://www.zghlxwxcb.cn/news/detail-636611.html
到了這里,關(guān)于使用python獲取cpu溫度的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!