最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python使用WMI檢測windows系統(tǒng)信息、硬盤信息、網(wǎng)卡信息的方法

 更新時間:2015年05月15日 15:21:03   作者:令狐不聰  
這篇文章主要介紹了python使用WMI檢測windows系統(tǒng)信息、硬盤信息、網(wǎng)卡信息的方法,涉及Python針對系統(tǒng)信息的相關(guān)操作技巧,需要的朋友可以參考下

本文實例講述了python使用WMI檢測windows系統(tǒng)信息、硬盤信息、網(wǎng)卡信息的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:

#!/usr/bin/env python 
# -*- coding: utf-8 -*- 
import wmi 
import sys,time,platform 
def get_system_info(os): 
  """ 
  獲取操作系統(tǒng)版本。 
  """ 
  print 
  print "Operating system:" 
  if os == "Windows": 
    c = wmi.WMI () 
    for sys in c.Win32_OperatingSystem(): 
      print '\t' + "Version :\t%s" % sys.Caption.encode("GBK") 
      print '\t' + "Vernum :\t%s" % sys.BuildNumber 
def get_memory_info(os): 
  """ 
  獲取物理內(nèi)存和虛擬內(nèi)存。 
  """ 
  print 
  print "memory_info:" 
  if os == "Windows": 
    c = wmi.WMI () 
    cs = c.Win32_ComputerSystem() 
    pfu = c.Win32_PageFileUsage() 
    MemTotal = int(cs[0].TotalPhysicalMemory)/1024/1024 
    print '\t' + "TotalPhysicalMemory :" + '\t' + str(MemTotal) + "M" 
    #tmpdict["MemFree"] = int(os[0].FreePhysicalMemory)/1024 
    SwapTotal = int(pfu[0].AllocatedBaseSize) 
    print '\t' + "SwapTotal :" + '\t' + str(SwapTotal) + "M" 
    #tmpdict["SwapFree"] = int(pfu[0].AllocatedBaseSize - pfu[0].CurrentUsage) 
def get_disk_info(os): 
  """ 
  獲取物理磁盤信息。 
  """ 
  print 
  print "disk_info:" 
  if os == "Windows": 
    tmplist = [] 
    c = wmi.WMI () 
    for physical_disk in c.Win32_DiskDrive(): 
      if physical_disk.Size: 
        print '\t' + str(physical_disk.Caption) + ' :\t' + str(long(physical_disk.Size)/1024/1024/1024) + "G" 
def get_cpu_info(os): 
  """ 
  獲取CPU信息。 
  """ 
  print 
  print "cpu_info:" 
  if os == "Windows": 
    tmpdict = {} 
    tmpdict["CpuCores"] = 0 
    c = wmi.WMI () 
    for cpu in c.Win32_Processor():       
      tmpdict["CpuType"] = cpu.Name 
    try: 
      tmpdict["CpuCores"] = cpu.NumberOfCores 
    except: 
      tmpdict["CpuCores"] += 1 
      tmpdict["CpuClock"] = cpu.MaxClockSpeed   
    print '\t' + 'CpuType :\t' + str(tmpdict["CpuType"]) 
    print '\t' + 'CpuCores :\t' + str(tmpdict["CpuCores"]) 
def get_network_info(os): 
  """ 
  獲取網(wǎng)卡信息和當(dāng)前TCP連接數(shù)。 
  """ 
  print 
  print "network_info:" 
  if os == "Windows": 
    tmplist = [] 
    c = wmi.WMI () 
    for interface in c.Win32_NetworkAdapterConfiguration (IPEnabled=1): 
        tmpdict = {} 
        tmpdict["Description"] = interface.Description 
        tmpdict["IPAddress"] = interface.IPAddress[0] 
        tmpdict["IPSubnet"] = interface.IPSubnet[0] 
        tmpdict["MAC"] = interface.MACAddress 
        tmplist.append(tmpdict) 
    for i in tmplist: 
      print '\t' + i["Description"] 
      print '\t' + '\t' + "MAC :" + '\t' + i["MAC"] 
      print '\t' + '\t' + "IPAddress :" + '\t' + i["IPAddress"] 
      print '\t' + '\t' + "IPSubnet :" + '\t' + i["IPSubnet"] 
    for interfacePerfTCP in c.Win32_PerfRawData_Tcpip_TCPv4(): 
        print '\t' + 'TCP Connect :\t' + str(interfacePerfTCP.ConnectionsEstablished) 
if __name__ == "__main__": 
  os = platform.system() 
  get_system_info(os) 
  get_memory_info(os) 
  get_disk_info(os) 
  get_cpu_info(os) 
  get_network_info(os) 

希望本文所述對大家的Python程序設(shè)計有所幫助。

相關(guān)文章

  • Python語言中Tuple的由來分析

    Python語言中Tuple的由來分析

    Tuple在Python中表示一種“大小固定的有序序列”,這篇文章主要介紹了Python語言中Tuple的由來,需要的朋友可以參考下
    2022-09-09
  • 自學(xué)python的建議和周期預(yù)算

    自學(xué)python的建議和周期預(yù)算

    在本篇文章中小編給大家分享了關(guān)于自學(xué)python的建議和周期預(yù)算,有興趣的朋友們可以學(xué)習(xí)參考下。
    2019-01-01
  • 用Python實現(xiàn)批量生成法務(wù)函代碼

    用Python實現(xiàn)批量生成法務(wù)函代碼

    大家好,本篇文章主要講的是用Python實現(xiàn)批量生成法務(wù)函代碼,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下
    2022-02-02
  • 利用Python第三方庫實現(xiàn)預(yù)測NBA比賽結(jié)果

    利用Python第三方庫實現(xiàn)預(yù)測NBA比賽結(jié)果

    今天給大家?guī)淼氖顷P(guān)于Python的相關(guān)知識,文章圍繞著利用Python實現(xiàn)預(yù)測NBA比賽結(jié)果展開,文中有非常詳細(xì)的介紹,需要的朋友可以參考下
    2021-06-06
  • Python實現(xiàn)手繪圖效果實例分享

    Python實現(xiàn)手繪圖效果實例分享

    在本篇文章里小編給大家整理了關(guān)于Python實現(xiàn)手繪圖效果,有需要的朋友們可以學(xué)習(xí)下。
    2020-07-07
  • Python+OpenCV采集本地攝像頭的視頻

    Python+OpenCV采集本地攝像頭的視頻

    這篇文章主要為大家詳細(xì)介紹了Python+OpenCV采集本地攝像頭的視頻,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-04-04
  • Python線性回歸圖文實例詳解

    Python線性回歸圖文實例詳解

    用python進(jìn)行線性回歸分析非常方便,有現(xiàn)成的庫可以使用比如numpy.linalog.lstsq、scipy.stats.linregress、pandas.ols等,這篇文章主要給大家介紹了關(guān)于Python線性回歸的相關(guān)資料,需要的朋友可以參考下
    2021-11-11
  • pytorch?tensor按廣播賦值scatter_函數(shù)的用法

    pytorch?tensor按廣播賦值scatter_函數(shù)的用法

    這篇文章主要介紹了pytorch?tensor按廣播賦值scatter_函數(shù)的用法,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-06-06
  • python 導(dǎo)入數(shù)據(jù)及作圖的實現(xiàn)

    python 導(dǎo)入數(shù)據(jù)及作圖的實現(xiàn)

    今天小編就為大家分享一篇python 導(dǎo)入數(shù)據(jù)及作圖的實現(xiàn),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-12-12
  • pytest中conftest.py使用小結(jié)

    pytest中conftest.py使用小結(jié)

    conftest.py文件是Pytest框架里面一個很重要的東西,本文主要介紹了pytest中conftest.py使用小結(jié),具有一定的參考價值,感興趣的可以了解一下
    2023-09-09

最新評論

永春县| 海城市| 安陆市| 北票市| 射洪县| 永安市| 马公市| 甘南县| 武夷山市| 贡觉县| 南康市| 丹棱县| 禄丰县| 利川市| 盐源县| 襄汾县| 鄂托克旗| 界首市| 迭部县| 玉田县| 慈溪市| 晋宁县| 新营市| 桓台县| 嘉黎县| 那坡县| 繁昌县| 南安市| 明水县| 沧州市| 子洲县| 青神县| 新丰县| 乾安县| 沙田区| 资中县| 武城县| 旅游| 竹山县| 马鞍山市| 盐津县|