使用python获取cpu温度

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() # 更新传感器数据
    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)  //延迟一秒

要用管理员模式启动pycharm

https: // openhardwaremonitor.org 获取.dll文件

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
乘风的头像乘风管理团队
上一篇 2023年8月22日
下一篇 2023年8月22日

相关推荐