python中查看操作系统基本信息的操作
1. 返回操作系统类型 posix 表示linux操作系统 nt 表示windows操作系统 2. 操作系统详细信息 3. 环境变量 4. 获取一段时间内CPU的占有率 import psutil import time # cpu_res = psutil.cpu_percent() # print(cpu_res) # 每一秒获取获取cpu的占有率 --->持久化保存 # 如何将时间和对应的cpu占有率去匹配 while True: # 获取当前时间和cpu的占有率 t = time.localtime() cpu_time = '%d:%d:%d' %(t.tm_hour,t.tm_min,t.tm_sec) cpu_res = psutil.cpu_percent() print(cpu_res) # 保存在文件中 with open('cpu.txt','a+') as f: f.write('%s %s \n' %(cpu_time,cpu_res)) time.sleep(1) 还可以使用pyecharts模块绘制图形 import random from pyecharts.charts import Line import pyecharts.options as opts # 获取折线图需要绘制的数据信息; x = [] y = [] with open(