Python code

Change IP to Number

import struct
import socket

def ip2num(addr):
    try:
        num = struct.unpack('!I', socket.inet_aton(addr))[0]
    except Exception as e:
        num = -1
    return num

Change MAC to Number

mac='34-02-86-F8-8D-50'
n = int(mac.replace('-', ''), 16)

Change Number to MAC

MAC = hex(n)

posted on 2016-02-24 10:15  kramer  阅读(162)  评论(0编辑  收藏  举报

导航