#!encoding=utf8
def func(ip):
ip_list = ip.split('.')
for i in range(len(ip_list)-1, -1, -1):
print(i)
if int(ip_list[i]) < 255:
ip_list[i] = str(int(ip_list[i]) + 1)
return '.'.join(ip_list)
else:
ip_list[i] = '0'
return "非法ip"
if __name__=='__main__':
# ip = '0.0.0.0'
ip = '0.0.0.255'
# ip = '255.255.255.0'
# ip = '255.255.255.254'
# ip = '10.10.0.254'
# ip = '255.255.255.255'
print(func(ip))
python算法IP自增
最新推荐文章于 2024-05-31 10:37:19 发布