import re
def is_valid_ip(ip):
pattern = r"^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
if re.match(pattern, ip):
return True
else:
return False
用python写一段ip地址校验
最新推荐文章于 2024-04-11 14:00:00 发布