• 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实现socket客户端和服务端简单示例
  • Python中operator模块的操作符使用示例总结
  • Python连接mysql数据库的正确姿势
  • python通过cookie模拟已登录状态的初步研究
  • Python实现求最大公约数及判断素数的方法
  • 深入解析Python中的集合类型操作符
  • Python编程中归并排序算法的实现步骤详解
  • 深入分析在Python模块顶层运行的代码引起的一个Bug
  • python实现的阳历转阴历(农历)算法
  • Python利用Beautiful Soup模块创建对象详解

文章分类

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

最近更新的内容

    • 再谈Python中的字符串与字符编码(推荐)
    • 部署Python的框架下的web app的详细教程
    • Python网络爬虫实例讲解
    • 简单介绍Python中用于求最小值的min()方法
    • 举例讲解Python中的身份运算符的使用方法
    • 深入解析Python中的list列表及其切片和迭代操作
    • Python实现从脚本里运行scrapy的方法
    • Python迭代用法实例教程
    • 跟老齐学Python之数据类型总结
    • 用python写asp详细讲解

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

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