Created
March 28, 2015 13:30
-
-
Save DecKen/de268f49e0e2308140a0 to your computer and use it in GitHub Desktop.
ip数值化转换
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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