📜  如何在 Python 中获取当前的 CPU 和 RAM 使用情况? - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:24.634000             🧑  作者: Mango

代码示例1
#!/usr/bin/env python
import psutil
# gives a single float value
psutil.cpu_percent()
# gives an object with many fields
psutil.virtual_memory()
# you can convert that object to a dictionary 
dict(psutil.virtual_memory()._asdict())