python获取mac地址

def Getphysicaladdress(self):

import uuid
node = uuid.getnode()
macHex = uuid.UUID(int=node).hex[-12:]
mac = []
for i in range(len(macHex))[::2]:
mac.append(macHex[i:i + 2])
mac = ':'.join(mac)
print('MAC:', mac)
posted @ 2022-02-25 10:03  老运维  阅读(275)  评论(0)    收藏  举报