def isipv4(value):
"""
Return whether or not given value is an IP version 4.
If the value is an IP version 4, this function returns ``True``, otherwise ``False``.
Examples::
>>> isipv4('127.0.0.1')
True
>>> isipv4('::1')
False
:param value: string to validate IP version 4
"""
try:
ip_addr = ipaddress.IPv4Address(value)
except ipaddress.AddressValueError:
return False
return ip_addr.version == 4
评论列表
文章目录