在我的Python应用程序中,我有一个IP地址字符串数组,看起来像这样:
我安装了
[
"50.28.85.81-140", // Matches any IP address that matches the first 3 octets, and has its final octet somewhere between 81 and 140
"26.83.152.12-194" // Same idea: 26.83.152.12 would match, 26.83.152.120 would match, 26.83.152.195 would not match
]
我安装了
netaddr
,虽然文档看起来很好,但我无法理解它。这一定非常简单——如何检查给定的IP地址是否与这些范围之一匹配?不需要特别使用netaddr
——任何简单的Python解决方案都可以。