Skip to content

Instantly share code, notes, and snippets.

@DecKen
Created March 28, 2015 13:30
Show Gist options
  • Save DecKen/de268f49e0e2308140a0 to your computer and use it in GitHub Desktop.
Save DecKen/de268f49e0e2308140a0 to your computer and use it in GitHub Desktop.
ip数值化转换
import socket
import struct
def ip2int(addr):
return struct.unpack("!I", socket.inet_aton(addr))[0]
def int2ip(addr):
return socket.inet_ntoa(struct.pack("!I", addr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment