Created
June 9, 2015 10:50
-
-
Save anonymous/cd4c4227133ad4166edd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
######################################################################## | |
# | |
# Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved | |
# | |
######################################################################## | |
''' | |
File: int2ip.py | |
Author: zhanglistar([email protected]) | |
Date: 2015/06/09 18:48:48 | |
''' | |
import sys | |
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)) | |
if __name__ == '__main__': | |
print int2ip(int(sys.argv[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment