Created
December 8, 2012 12:56
-
-
Save mike-zhang/4240150 to your computer and use it in GitHub Desktop.
windows下获取MAC地址(python代码)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# just in windows | |
import os | |
var = os.popen("wmic nicconfig get MACAddress").read() | |
#print var | |
macList = [] | |
for x in var.split(" \r\n"): | |
if len(x.strip()) > 0 and x.find("MACAddress"): | |
if x not in macList:macList.append(x) | |
for macAddr in macList:print macAddr | |
raw_input("Press Enter to continue") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# just in windows | |
import os | |
var = os.popen("getmac /NH /FO csv").read() | |
#print var | |
macList = [] | |
for line in var.split("\n") : | |
#print line.split(',')[0][1:-1] | |
macAddrTmp = line.split(',')[0][1:-1] | |
if macAddrTmp not in macList : macList.append(macAddrTmp) | |
for macAddr in macList:print macAddr | |
raw_input("Press Enter to continue") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment