# -*- coding: utf-8 -*- # 打开文件 file = open("/sys/class/thermal/thermal_zone0/temp") # 读取结果,并转换为浮点数 temp = float(file.read()) / 1000 # 关闭文件 file.close() # 向控制台打印 print "temp : %.1f" %temp
在temp.py目录下输入以下指令执行脚本
执行脚本
python temp.py
执行返回
temp : 49.2
# -*- coding: utf-8 -*- # 打开文件 file = open("/sys/class/thermal/thermal_zone0/temp") # 读取结果,并转换为浮点数 temp = float(file.read()) / 1000 # 关闭文件 file.close() # 向控制台打印 print "temp : %.1f" %temp
在temp.py目录下输入以下指令执行脚本
执行脚本
python temp.py
执行返回
temp : 49.2