Created
July 25, 2014 16:23
-
-
Save otms61/3ba3b480b8a97a3c9ccf to your computer and use it in GitHub Desktop.
summarize ip address range
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
from ipaddress import ip_address, summarize_address_range | |
first = ip_address(u'192.168.1.0') | |
last = ip_address(u'192.168.1.255') | |
print list(summarize_address_range(first, last)) | |
# output | |
# [IPv4Network(u'192.168.1.0/24')] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
python 2系で実行するにはipaddressというライブラリが必要
sudo easy_install ipaddress
で導入できる。