在 Python 中获取总物理内存 [英] Get total physical memory in Python
本文介绍了在 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.
推荐答案
跨平台解决方案的最佳选择是使用 psutil 包(可在 PyPI 上获得).
your best bet for a cross-platform solution is to use the psutil package (available on PyPI).
import psutil
psutil.virtual_memory().total # total physical memory in Bytes
virtual_memory
的文档在这里.
这篇关于在 Python 中获取总物理内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文