普通 IP 转换为十进制 IP,ip转换为十进制,[Python]代码Py


[Python]代码

Python语言: python.普通 IP 转换为十进制 IP#encoding=utf-8#IP To Decimal#This IP is : g.cnIP = '203.208.33.100'IP1 = IP.split('.')[0]IP2 = IP.split('.')[1]IP3 = IP.split('.')[2]IP4 = IP.split('.')[3]print 'Your IP is : ' + IPprint '------------------------------------------------------------'print 'Your Decimal IP is : ' + \        str(int(IP1)*256**3 + \            int(IP2)*256**2 + \            int(IP3)*256 + \            int(IP4))

评论关闭