通过ip网段生成ip地址

import ipaddress

net4 = ipaddress.ip_network('120.78.0.0/16', strict=False)
with open('b.txt','w',encoding='utf-8') as f:
    for x in net4.hosts():
        f.write(str(x)+'
')
原文地址:https://www.cnblogs.com/lovesickness/p/13291813.html