Sunday, February 7, 2016

Python to get MAC address using uuid, run on Raspberry Pi/Raspbian Jessie


Python example code to get MAC address using uuid, run on Raspberry Pi/Raspbian Jessie, tested on both Python 2 and Python 3.


PythonGetMac.py
from uuid import getnode as get_mac
mac = get_mac()
print(mac)
print(hex(mac))
macString = ':'.join(("%012X" % mac)[i:i+2] for i in range(0, 12, 2))
print('[' + macString + ']')


Related:
Java to list Network Interface Parameters (include MAC address), run on Raspberry Pi/Raspbian Jessie
c language to get MAC address, run on Raspberry Pi/Raspbian Jessie



No comments: