MySQL怎样存储IP地址 – cn三少 – 博客园 https://www.cnblogs.com/cnsanshao/p/3326648.html
# coding: utf-8
import socket
import struct
def IpToInt(ipStr):
return socket.ntohl(struct.unpack(‘I’, socket.inet_aton(ipStr))[0])
def IntToIp(ipInt):
return socket.inet_ntoa(struct.pack(‘I’, socket.htonl(ipInt)))