![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
https://files.pythonhosted.org/packages/e1/66/b6dd22472bb027556849876beae2dd4dca3a4eaf2dd3039277b4edb8c6af/IPy-1.00.tar.gz
python setup.py install
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
from the IPy Import the IP ip_s = INPUT ( '' ) IPS = the IP (ip_s) IF len (IPS)>. 1 : Print ( ' NET: S% ' % (ips.net ())) # Print ( ' netmake:% S ' % (ips.netmask ())) # IP mask Print ( ' broadcase: S% ' % (ips.broadcast ())) # gateway Print ( ' Reverse address: S% ' % (ips.reverseName ()) ) # reverse IP Print ( ' Subnet: S% ' % (len (IPS))) # IP segment number of the else : Print ( ' Reverse address: S% ' % (ips.reverseName ())) Print ( ' binary IP:% S ' % (ips.strBin ())) # IP converting binary Print ( ' IpType: S% ' % (ips.iptype ())) # type
Detailed multi-network computing method
Comparative whether a relationship exists comprises two segments, overlapping, etc., such as the same network but different prefixlen be considered unequal segments, such as 10.0.0.0/16 10.0.0.0/24 not equal, even further but at the same prefixlen different network addresses, also not considered equal, not equal as 10.0.0.0/16 192.0.0.0/16. IPy support similar to compare numerical data to help IP object to be compared.
-
Compare the size of the IP
>>> IP('10.0.0.0/24') < IP('12.0.0.0/24') True
-
Determining whether the IP address and network segment to another network segment comprising
>>> '192.168.1.100' in IP('192.168.1.0/24') True >>> IP('192.168.1.0/24') in IP('192.168.0.0/16') True
-
Determining whether the two networks overlap (Overlaps Method) present
>>> IP('192.168.0.0/23').overlaps('192.168.1.0/24') 1 >>> IP('192.168.1.0/24').overlaps('192.168.2.0/24') 0