validators.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:NeoAlchemy 作者: TwoBitAlchemist 项目源码 文件源码
def IPv6(ip_addr):
    """
    Validate a string as an IPv6 address. See `man 3 inet_pton` for details.

    Availability is platform-dependent.
    """
    ip_addr = str(ip_addr)

    try:
        socket.inet_pton(socket.AF_INET6, ip_addr)
    except socket.error:
        raise ValueError('Invalid IPv6 address: %s' % ip_addr)
    except AttributeError:
        raise ValueError('IPv6 validation unavailable on this platform.')

    return ip_addr
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号