python-获取本机mac地址
2017-06-21 19:18
204 查看
1 #!/usr/bin/env python 2 #-*- coding:utf-8 -*- 3 ############################ 4 #File Name: getmac.py 5 #Author: frank 6 #Mail: frank0903@aliyun.com 7 #Created Time:2017-06-05 17:10:51 8 ############################ 9 10 import uuid 11 12 def get_mac_address(): 13 mac=uuid.UUID(int = uuid.getnode()).hex[-12:].upper() 14 #return '%s:%s:%s:%s:%s:%s' % (mac[0:2],mac[2:4],mac[4:6],mac[6:8],mac[8:10],mac[10:]) 15 return ":".join([mac[e:e+2] for e in range(0,11,2)]) 16 17 if __name__ == '__main__': 18 ##name = "test_name" 19 #namespace = "test_namespace" 20 21 print get_mac_address() 22 ''' 23 u=uuid.uuid1() # 带参的方法参见Python Doc 24 print u 25 #print uuid.uuid3(namespace, name) 26 #print uuid.uuid4() 27 #print uuid.uuid5(namespace, name) 28 node1=uuid.getnode() #获取mac地址 29 print ("node1:%s"%node1) 30 print ("hex(node1):%s"%hex(node1)) 31 print ("uuid.bytes:%s"%repr(u.bytes)) 32 print ("uuid.bytes_le:%s"%repr(u.bytes_le)) 33 print ("hex:", u.hex) 34 print 'int :', u.int 35 print 'urn :', u.urn 36 print 'variant :', u.variant 37 print 'version :', u.version 38 #print get_mac_address() 39 '''
相关文章推荐
- python通过scapy获取局域网所有主机mac地址示例
- python获取mac地址,生成mac地址
- python 获取 mac 地址 的代码举例
- Python获取MAC地址
- python脚本获取主机Mac地址
- python获取本机mac地址和ip地址的方法
- python获取本机mac地址和ip地址的方法
- python通过scapy获取局域网所有主机mac地址示例
- python 获取 mac 地址 的代码
- python获取本地的IP地址及mac地址
- Python 获取 网卡 MAC 地址
- python 获取mac地址
- Python获取Mac地址
- java简单的获取windows系统网卡mac地址
- 获取Mac地址
- java简单的获取windows系统网卡mac地址
- [译]获取系统网络MAC地址的三种方法
- 网卡MAC地址相关信息大全-4 获取远程网卡MAC地址