16 Star 44 Fork 45

现任明教教主-乾颐堂 / qytang_Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
2016.03.09 获取本机MAC 659 Bytes
一键复制 编辑 原始数据 按行查看 历史
现任明教教主-乾颐堂 提交于 2016-03-08 10:42 . new file
#!/usr/bin/python3.4
# -*- coding=utf-8 -*-
import os
import re
def get_mac_address(iface):
#data = commands.getoutput("ifconfig " + iface)
data = os.popen("ifconfig " + iface).read()
words = data.split()
found = 0
location = 0
index = 0
for x in words:
if re.match('\w\w:\w\w:\w\w:\w\w:\w\w:\w\w', x):
found = 1
index = location
break
else:
location = location + 1
if found == 1:
mac = words[index]
else:
mac = 'Mac not found'
return mac
if __name__ == "__main__":
print(get_mac_address('eno33554944'))
Python
1
https://gitee.com/qytang/qytang_Python.git
git@gitee.com:qytang/qytang_Python.git
qytang
qytang_Python
qytang_Python
master

搜索帮助