Created
February 13, 2015 11:34
-
-
Save akash0x53/2bc7e6efe089a79eb8a0 to your computer and use it in GitHub Desktop.
convert uuid.getnode to MAC address format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import uuid | |
>>> mac="%12X" % uuid.getnode() | |
>>> mac | |
'48D224921B7C' | |
>>> mac[::2] | |
'4D2917' | |
>>> mac[1::2] | |
'8242BC' | |
>>> map(None, *(mac[::2], mac[1::2])) | |
[('4', '8'), ('D', '2'), ('2', '4'), ('9', '2'), ('1', 'B'), ('7', 'C')] | |
>>> ':'.join([''.join(i) for i in map(None, *(mac[::2], mac[1::2]))]) | |
'48:D2:24:92:1B:7C' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment