获取电脑温度
import psutil
def get_all_temperatures():
try:
# 获取传感器信息
temps = psutil.sensors_temperatures()
if not temps:
print("没有传感器信息")
return
# 打印传感器信息
for name, entries in temps.items():
print(f"{name}:")
for entry in entries:
# 为不同的传感器提供详细描述
if name == "coretemp":
label = entry.label or "CPU 核心"
elif name == "acpitz":
label = entry.label or "主板温度"
else:
label = entry.label or "温度"
print(f" {label}: {entry.current}°C (高温: {entry.high}°C, 临界温度: {entry.critical}°C)")
except Exception as e:
print(f"获取温度失败: {e}")
if __name__ == "__main__":
get_all_temperatures()
本文作者: 永生
本文链接: https://yys.zone/detail/?id=365
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!
发表评论
评论列表 (0 条评论)
暂无评论,快来抢沙发吧!