标签:python pytho utf-8 author mac repr version uuid yun
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 pytho utf-8 author mac repr version uuid yun
原文地址:http://www.cnblogs.com/black-mamba/p/7061342.html