python ip和int 互转函数

def Ip2Int(ip):
    
import struct,socket
    
return struct.unpack("!I",socket.inet_aton(ip))[0]


def Int2Ip(i):
    
import socket,struct
    
return socket.inet_ntoa(struct.pack("!I",i))

原文地址:https://www.cnblogs.com/thh/p/806866.html