def getip():
replace2 = ipd.replace(' ','.')
ipsplit = replace2.split('.')
iplist = []
ip1 = ipsplit[0]
for ip2 in range(int(ipsplit[1]),int(ipsplit[5])+1):
for ip3 in range(int(ipsplit[2]), int(ipsplit[6])+1):
for ip4 in range(int(ipsplit[3]), int(ipsplit[7]) + 1):
iplist.append(str(ip1)+'.'+str(ip2)+'.'+str(ip3)+'.'+str(ip4))
return iplist
例子:
def getip():
replace2 = ipd.replace(' ','.')
ipsplit = replace2.split('.')
iplist = []
ip1 = ipsplit[0]
for ip2 in range(int(ipsplit[1]),int(ipsplit[5])+1):
for ip3 in range(int(ipsplit[2]), int(ipsplit[6])+1):
for ip4 in range(int(ipsplit[3]), int(ipsplit[7]) + 1):
iplist.append(str(ip1)+'.'+str(ip2)+'.'+str(ip3)+'.'+str(ip4))
return iplist
getip('192.168.1.1 192.168.1.255')