发布时间:2019-09-21 10:47:08编辑:auto阅读(4050)
不同的linux发行版可能获取CPU温度文件的目录不所不同,可自行百度。
# fedora filepath :'/sys/class/hwmon/hwmon0/device/hwmon/hwmon0/temp2_input'
# respberrypi filepath : '/sys/class/thermal/thermal_zone0/temp'
with open('/sys/class/hwmon/hwmon0/device/hwmon/hwmon0/temp2_input', 'rt') as f:
# 读取结果,并转换为整数
temp = int(f.read()) / 1000
# 向控制台打印
print ("temp : " + str(temp))
上一篇: python 中英文时间转换
下一篇: python关于return的用法
51292
50743
41340
38151
32621
29519
28369
23242
23209
21532
1606°
2340°
1940°
1881°
2208°
1925°
2608°
4382°
4231°
3002°