import psutil
a = psutil.cpu_count() # CPU逻辑数量
b = psutil.cpu_times() #CPU运行时间
c = psutil.cpu_percent(interval=1, percpu=True) #当前逻辑CPU使用率
d = psutil.virtual_memory() #物理内存使用情况
e = psutil.net_io_counters()
print("CPU数量={}".format(a))
print("当前逻辑CPU使用率{}".format(c))
print("CPU运行时间{}".format(b))
print("运行内存 总{:0.2f}G--使用量{:0.2f}G--使用率{}%--空闲{:0.2f}G".format(d[0]/(1024*1024*1024), d[3]/(1024*1024*1024), d[2], d[4]/(1024*1024*1024)))
print("网络接口信息 发包流量{:0.2f}G--收包流量{:0.2f}G--发包个数{}--收包个数{}".format(e[0]/(1024*1024*1024), e[1]/(1024*1024*1024), e[2], e[3]))
python psutil 获取windows 状态
最新推荐文章于 2025-04-09 08:15:00 发布