树莓派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
#! /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
相关文章推荐
- TTTAttributedLabel使用介绍(转)
- JVM跟踪类的加载
- js判断UUID正则表达式
- Java关键字与保留字说明及使用
- [转】IIS:Do not nest virtual directories
- ios开发笔记-2-毛玻璃效果
- GIT常用命令
- Hadoop基本概念
- 解析漏洞总结
- MySQL 密码安全
- Android 系统中Parcelable和Serializable的区别
- Linux进程优先级的调整方法
- Socket
- sql server 分页
- Git服务器环境搭建
- 15个超实用的php正则表达式
- Python设置Socket代理及实现远程摄像头控制的例子
- AspectJ切入点语法详解
- Android UI开发: 横向ListView(HorizontalListView)及一个简单相册的完整实现 (附源码下载)
- LoadRunner中数组的用法