How to get the local mac address?

Scott David Daniels scott.daniels at acm.org
Wed Dec 14 21:10:32 CET 2005


Daniel Crespo wrote:
> Hi, I tried: ...

>     # Convert binary data into a string.
>     macaddr = ''
>     for intval in struct.unpack('BBBBBB', buffer):
>         if intval > 15:
>             replacestr = '0x'
>         else:
>             replacestr = 'x'
>         macaddr = ''.join([macaddr, hex(intval).replace(replacestr, '')])

Replace the above by:
       return '%02X' * 6 % struct.unpack('BBBBBB', buffer)

(doesn't help with win98, though)

-- 
-Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list