获取Python的总物理内存 [英] Get total physical memory in Python

查看:218
本文介绍了获取Python的总物理内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以不可知的方式获取Python中的总物理内存?我不需要用过的内存,只需要总的物理内存.

How can I get the total physical memory within Python in a distribution agnostic fashion? I don't need used memory, just the total physical memory.

推荐答案

您最好的跨平台解决方案是使用 PyPI 上可用).

your best bet for a cross-platform solution is to use the psutil package (available on PyPI).

from psutil import virtual_memory

mem = virtual_memory()
mem.total  # total physical memory available

virtual_memory的文档位于此处.

这篇关于获取Python的总物理内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆