码迷,mamicode.com
首页 > 编程语言 > 详细

3-python常用模块

时间:2018-04-03 19:15:37      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:ons   网络   virtual   常用   系统   div   时间   \n   登录   

  • 系统信息-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
#下次再说

 

3-python常用模块

标签:ons   网络   virtual   常用   系统   div   时间   \n   登录   

原文地址:https://www.cnblogs.com/jabbok/p/8677808.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!