Python 获取cpu、内存利用率

获取cpu、内存利用率

Python 获取cpu、内存利用率_第1张图片

# -*- coding: latin1 -*-
import psutil
cpuPercent =0
psutil.cpu_percent()
while True:
    vm = psutil.virtual_memory()
    memoryPercent = vm.percent
    cpuPercent = psutil.cpu_percent(1) *10
    print("cpuPercent:"+str(cpuPercent)+" %")
    print("memory:"+str(memoryPercent)+" %")   
    input("any key")

你可能感兴趣的:(Python,python,psutil)