您的位置:首页 > 其它

树莓派02-获取CPU温度

2015-11-13 15:28 363 查看
pi@raspberrypi ~ $ cat temperature.py
#! /usr/bin/python
#-*- coding: utf-8 -*-
#open file
file = open("/sys/class/thermal/thermal_zone0/temp")
#读取结果,并转换为浮点数
temp = float(file.read())/1000
#关闭文件
file.close()
#向控制台打印
print "temp : %.1f" %temp

pi@raspberrypi ~ $ ./temperature.py
temp : 42.2

原文链接如下:http://bbs.ickey.cn/group-topic-id-35431.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: