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   kramer  阅读(163)  评论(0编辑  收藏  举报

导航

< 2025年1月 >
29 30 31 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31 1
2 3 4 5 6 7 8
点击右上角即可分享
微信分享提示