python获得linux物理内存大小

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

python获得linux物理内存大小:

import re
def get_physical_memory_in_kb():
    meminfo = open('/proc/meminfo').read()
    matched = re.search(r'^MemTotal:\s+(\d+)', meminfo)
    return int(matched.groups()[0])