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