"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "", "" "". "" "" "" "" "" "" "" "," "" "" "," "" "" "," "" "," "" ">> CPU Information .py>> Author: Liu Yang>> e-mail: [email protected] "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "." "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "#!/usr/bin/env python#-*-coding:utf-8-*-import sys,osimport Psutilfrom CPU Usage Import cpu_utilizationdef cpu_message (): # total number of cores = physical processor x cores per processor Cpu_count=psutil.cpu_count () # Number of physical cores, number of processors Cpu_count_p=psutil.cpu_count (FALSE) # CPU Frequency scpufreq (current=1792.0, min=0.0, max=1992.0) cpu_freq=p Sutil.cpu_freq () # Current processor single core maximum frequency Cpu_freq_max=cpu_freq.max # Current single-core processor frequency Cpu_freq_current=cpu_freq.current # CP U Utilization cpu_used_percent=cpu_utilization () print ("Total cores:%s Physical cores:%s CPU Max frequency:%shz CPU Current frequency:%shz CPU usage:%0.2f"% (cpu_count,cpu_count_p,cpu_freq_max,cpu_freq_current,cpu_used_percent)) if __name__ = = ' __main__ ': While True:cpu_message () # Os.system ("CLS")
[Python Study notes]cpu information