這裡還是要介紹python下面的wim這個模塊,這次我們來介紹如何得到本機的網卡類型,ip和mac地址,代碼如下:
#-*- encoding: utf-8 -*-
Created on 2011-3-1
@author: hack7th
import wmi
import time
c = wmi.WMI()
for interface in c.Win32_NetworkAdapterConfiguration (IPEnabled=1):
print interface.Description, interface.MACAddress
for ip_address in interface.IPAddress:
print ip_address
#-*- encoding: utf-8 -*-
Created on 2011-3-1
@author: hack7th
import wmi
import time
c = wmi.WMI()
for interface in c.Win32_NetworkAdapterConfiguration (IPEnabled=1):
print interface.Description, interface.MACAddress
for ip_address in interface.IPAddress:
print ip_address