psutil模块
psutil
import psutil,datetime #cpu print("cpu_times:\t",psutil.cpu_percent(),"\n") #内存 mem = psutil.virtual_memory() print("mem_total:\t",int(mem.total/1024/1024),"MB") print("mem_free:\t",int(mem.free/1024/1024),"MB") #磁盘 partitions = psutil.disk_partitions() print("the partitions:\t",partitions,"\n") usage_c = psutil.disk_usage('C:\\').percent print("disk c\ usage:\t",usage_c,"%\n") disk_io = psutil.disk_io_counters(perdisk=True) print("disk_io:\t",disk_io,"\n") #网络 net_io = psutil.net_io_counters() print("net_io:\t",net_io,"\n") #登录用户 login_users = psutil.users()[0][0] print("login_user:\t",login_users,"\n") #开机时间 boot_time = datetime.datetime.fromtimestamp(psutil.boot_time()) print("boot_time:\t",boot_time,"\n") #进程 ps = psutil.pids() print("ps:\t",ps,"\n") #IP #下次再说