[daily][python2] int型IP地址与string型IP地址互转

使用python2,类似如下操作。

>>> import socket
>>> import struct
>>> socket.ntohl(struct.unpack("=I", socket.inet_aton("10.0.0.3"))[0])
167772163L
>>> socket.inet_ntoa(struct.pack("=I", socket.htonl(167772163)))
'10.0.0.3'
>>> 
原文地址:https://www.cnblogs.com/hugetong/p/10020054.html