Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将多个 IP 范围转换为 CIDR 表示法?我发现的只是ip2cidr 服务,但我有 >200K IP 记录。
http://pypi.python.org/pypi?%3Aaction=search&term=cidr&submit=search
使用网络地址:
from netaddr import * ips = ['192.168.37.111', '192.168.37.112'] all_ips = list(iter_iprange(ips[0], ips[1])) ip_address = cidr_merge(all_ips) cidr = [] for ip in ip_address: cidr.append(str(ip.cidr))