#!/usr/bin/env python
From IPy import IP
ip_s = raw_input (' Please input an IP or net-range: ')
ips = IP (ip_s)
If Len (IPs) > 1:
Print (' Net:%s '% ips.net ())
Print (' netmask:%s '% ips.netmask ())
Print (' Broadcast:%s '% ips.broadcast ())
Print (' Reverse address:%s '% ips.reversenames () [0])
Print (' Subnet:%s '% len (IPS))
Else
Print (' Reverse address:%s '% ips.reversenames () [0])
Print (' hexadecimal:%s '% Ips.strhex ())
Print (' Binary IP:%s '% Ips.strbin ())
Print (' Iptype:%s '% Ips.iptype ())
1.please input an IP or net-range:192.168.20.140
Reverse address:140.20.168.192.in-addr.arpa.
hexadecimal:0xc0a8148c
Binary ip:11000000101010000001010010001100
Iptype:private
2.please input an IP or net-range:192.168.20.0/24
net:192.168.20.0
netmask:255.255.255.0
broadcast:192.168.20.255
Reverse address:20.168.192.in-addr.arpa.
subnet:256
Learn python automation Koriyuki input IP or network segment, return to network. Information such as masks