''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' >>文件: cpu信息.py >>作者: liu yang >>邮箱: liuyang0001@outlook.com ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' #!/usr/bin/env python # -*- coding: utf-8 -*- import sys,os import psutil from cpu使用率 import cpu_utilization def cpu_message(): # 总核心数=物理处理器x每个处理器的核心数 cpu_count=psutil.cpu_count() # 物理核心数,处理器数量 cpu_count_p=psutil.cpu_count(False) # cpu频率 scpufreq(current=1792.0, min=0.0, max=1992.0) cpu_freq=psutil.cpu_freq() # 当前处理器单核最高频率 cpu_freq_max=cpu_freq.max # 目前单核处理器频率 cpu_freq_current=cpu_freq.current # cpu使用率 cpu_used_percent=cpu_utilization() print("总核心数:%s 物理核心数:%s cpu最大频率:%sHz cpu当前频率:%sHz cpu使用率:%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")