Python获取内存、CPU利用率,CPU温度
1 import psutil
2
3
4 # 获取CPU温度
5 def get_cpu_heat():
6 temperatures = psutil.sensors_temperatures()
7 cpu_temperatures = temperatures['coretemp']
8 average_temperature = sum(sensor.current for sensor in cpu_temperatures) / len(cpu_temperatures)
9 return average_temperature