by
0
6
311k
3
Top 1% !
Popular
Pearl of Wisdom
Tagged
Easy-to-find
Specified
Popularity: 3474th place
This snippet is Public
Languagepython
LicenseMIT_X11

Get MAC address of current interface in Python

This python uses uuid.getnode to get current mac address as an integer.
It formats the number in a standard mac address form (i.e. bytes splitted by :)
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/435/Get-MAC-address-of-current-interface-in-?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
import uuid print ':'.join(['{:02x}'.format((uuid.getnode() >> i) & 0xff) for i in range(0,8*6,8)][::-1])
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus