运行在Linux下的Python程式获取MAC地址,其简单的方法如下:
import uuid mac = uuid.UUID(int = uuid.getnode()).hex[-12:].upper() print macmac1 = '%s:%s:%s:%s:%s:%s' % (mac[0:2],mac[2:4],mac[4:6],mac[6:8],mac[8:10],mac[10:])mac2 = ":".join([mac[e:e+2] for e in range(0,11,2)])print mac1print mac2