#!/usr/bin/env python
#-*- coding:utf-8 -*-

''' 统计系统内存信息 '''  

with open('/proc/meminfo') as fd:
    for line in fd:
        if line.startswith('MemTotal'):
            MemTotal = line.split()[1]
            continue
        if line.startswith('MemFree'):
            MemFree = line.split()[1]
            break
        
print "总内存:%sM" % (int(MemTotal)/1024)
print "剩余内存:%sM" % (int(MemFree)/1024)

 

 

 

 

 

    

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
  • 2022-01-14
  • 2021-06-19
  • 2021-07-04
  • 2021-09-15
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案