抱歉,如果这有点含糊,或者已经被问到了,但我不确定术语,所以我不能谷歌它。我正在寻找的是如何将psutil.virtual_memory()提供的参数赋给不同的变量。
例如,调用psutil.virtual_memory()会使(total=8374149120L, available=1247768576L, percent=85.1, used=8246628352L, free=127520768L, active=3208777728, inactive=1133408256, buffers=342413312L, cached=777834496)
我只想获取percent值,并将其赋给一个变量。我怎么能这么做呢?
文档:https://code.google.com/p/psutil/wiki/Documentation#Memory
发布于 2013-05-20 01:52:23
它返回一个namedtuple (名为vrem),因此使用percent = psutil.virtual_memory().percent
>>> help(psutil.virtual_memory)
Help on function virtual_memory in module psutil:
virtual_memory()
Return statistics about system memory usage as a namedtuple
including the following fields, expressed in bytes:https://stackoverflow.com/questions/16637637
复制相似问题