首页 > 编程语言 > 详细

Python计算两个IP段之间的有效IP地址

时间:2021-03-29 14:20:23      阅读:26      评论:0      收藏:0      [点我收藏+]

Can anyone think of an algorithm to put all of the addresses between two others and put them in a list (using python)? For example:

try:
    from ipaddress import ip_address
except ImportError:
    from ipaddr import IPAddress as ip_address


def findIPs(start, end):
    start = ip_address(start)
    end = ip_address(end)
    result = []
    while start <= end:
        result.append(str(start))
        start += 1
    return result


print(findIPs(‘111.111.111.0‘, ‘111.111.111.3‘))

Python计算两个IP段之间的有效IP地址

原文:https://www.cnblogs.com/blackxu/p/14591841.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!