python监控本机cpu的利用百分比情况
import wmi import time c = wmi.WMI() while True: for cpu in c.Win32_Processor(): timestamp = time.strftime('%a, %d %b %Y %H:%M:%S', time.localtime()) print '%s | Utilization: %s: %d %%' % (timestamp, cpu.DeviceID, cpu.LoadPercentage) time.sleep(5)