读取树梅派内存使用情况

来源:互联网 发布:网上购物商城源码 编辑:程序博客网 时间:2024/06/18 05:10

方法一:

 free -m





方法二:


建立一个文件  RAM.py 运行.


#!usr/bin/python#-*- coding: UTF-8 -*-import osimport timeimport re while True:    # Get memory usage info    cpuinfo = os.popen("free -m | grep Mem")    strMem = cpuinfo.readline()     # Get all the number from string    numMem = re.findall("\d+", strMem)    print("Total memory: %sMB, Used memory: %sMB, Memory usage:%d%%" \        %(numMem[0], numMem[1], int(numMem[1])*100/int(numMem[0])))     time.sleep(3)


运行结果:





参考:http://www.eefocus.com/nightseas/blog/15-05/312904_949ea.html

原创粉丝点击