• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python使用wmi模块获取windows下的系统信息 监控系统

python使用wmi模块获取windows下的系统信息 监控系统

作者:mrr 字体:[增加 减小] 来源:互联网

mrr 通过本文主要向大家介绍了python wmi模块,python wmi,python安装wmi,python wmi下载,windows wmi等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

Python用WMI模块获取Windows系统的硬件信息:硬盘分区、使用情况,内存大小,CPU型号,当前运行的进程,自启动程序及位置,系统的版本等信息。

本文实例讲述了python使用wmi模块获取windows下的系统信息 监控系统

 #!/usr/bin/env python 
 # -*- coding: utf- -*- 
 #http://www.cnblogs.com/liu-ke/
 import wmi 
 import os 
 import sys 
 import platform 
 import time 
 def sys_version(): 
   c = wmi.WMI () 
   #获取操作系统版本 
   for sys in c.Win_OperatingSystem(): 
     print "Version:%s" % sys.Caption.encode("UTF"),"Vernum:%s" % sys.BuildNumber 
     print sys.OSArchitecture.encode("UTF")#系统是位还是位的 
     print sys.NumberOfProcesses #当前系统运行的进程总数
 def cpu_mem(): 
   c = wmi.WMI ()    
   #CPU类型和内存 
   for processor in c.Win_Processor(): 
     #print "Processor ID: %s" % processor.DeviceID 
     print "Process Name: %s" % processor.Name.strip() 
   for Memory in c.Win_PhysicalMemory(): 
     print "Memory Capacity: %.fMB" %(int(Memory.Capacity)/) 
 def disk(): 
   c = wmi.WMI ()  
   #获取硬盘分区 
   for physical_disk in c.Win_DiskDrive (): 
     for partition in physical_disk.associators ("Win_DiskDriveToDiskPartition"): 
       for logical_disk in partition.associators ("Win_LogicalDiskToPartition"): 
         print physical_disk.Caption.encode("UTF"), partition.Caption.encode("UTF"), logical_disk.Caption 
   #获取硬盘使用百分情况 
   for disk in c.Win_LogicalDisk (DriveType=): 
     print disk.Caption, "%.f%% free" % (. * long (disk.FreeSpace) / long (disk.Size)) 
 def network(): 
   c = wmi.WMI ()  
   #获取MAC和IP地址 
   for interface in c.Win_NetworkAdapterConfiguration (IPEnabled=): 
     print "MAC: %s" % interface.MACAddress 
   for ip_address in interface.IPAddress: 
     print "ip_add: %s" % ip_address 
   print 
 def main(): 
   sys_version() 
   cpu_mem() 
   #disk() 
   #network() 
 if __name__ == '__main__': 
   main() 
   print platform.system() 
   print platform.release() 
   print platform.version() 
   print platform.platform() 
   print platform.machine()
</div>

以上内容是关于python使用wmi模块获取windows下的系统信息 监控系统的相关知识,希望对大家有所帮助。

</div>

您可能想查找下面的文章:

  • python使用wmi模块获取windows下的系统信息 监控系统
  • python使用wmi模块获取windows下的系统信息 监控系统
  • python使用wmi模块获取windows下硬盘信息的方法
  • python使用WMI检测windows系统信息、硬盘信息、网卡信息的方法

相关文章

  • Python实现批量检测HTTP服务的状态
  • Python实现处理管道的方法
  • python为tornado添加recaptcha验证码功能
  • 在Python的Django框架中simple-todo工具的简单使用
  • python33 urllib2使用方法细节讲解
  • python完成FizzBuzzWhizz问题(拉勾网面试题)示例
  • Python的Flask框架应用程序实现使用QQ账号登录的方法
  • Python常用小技巧总结
  • Python中列表、字典、元组数据结构的简单学习笔记
  • python实现提取百度搜索结果的方法

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • Python中.py文件打包成exe可执行文件详解
    • python读取word文档的方法
    • Python找出list中最常出现元素的方法
    • Python实现随机生成任意数量车牌号
    • python如何实现远程控制电脑(结合微信)
    • Python实现的简单发送邮件脚本分享
    • 举例简单讲解Python中的数据存储模块shelve的用法
    • 浅析Python 中整型对象存储的位置
    • python元组操作实例解析
    • Python自动调用IE打开某个网站的方法

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有