本文整理汇总了Python中pip._vendor.ipaddress.ip_address方法的典型用法代码示例。如果您正苦于以下问题:Python ipaddress.ip_address方法的具体用法?Python ipaddress.ip_address怎么用?Python ipaddress.ip_address使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pip._vendor.ipaddress
的用法示例。
在下文中一共展示了ipaddress.ip_address方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _ipaddress_match
# 需要导入模块: from pip._vendor import ipaddress [as 别名]
# 或者: from pip._vendor.ipaddress import ip_address [as 别名]
def _ipaddress_match(ipname, host_ip):
"""Exact matching of IP addresses.
RFC 6125 explicitly doesn't define an algorithm for this
(section 1.7.2 - "Out of Scope").
"""
# OpenSSL may add a trailing newline to a subjectAltName's IP address
# Divergence from upstream: ipaddress can't handle byte str
ip = ipaddress.ip_address(_to_unicode(ipname).rstrip())
return ip == host_ip
示例2: inet_pton
# 需要导入模块: from pip._vendor import ipaddress [as 别名]
# 或者: from pip._vendor.ipaddress import ip_address [as 别名]
def inet_pton(_, host):
if isinstance(host, bytes):
host = host.decode('ascii')
return ipaddress.ip_address(host)
示例3: inet_pton
# 需要导入模块: from pip._vendor import ipaddress [as 别名]
# 或者: from pip._vendor.ipaddress import ip_address [as 别名]
def inet_pton(_, host):
if isinstance(host, six.binary_type):
host = host.decode('ascii')
return ipaddress.ip_address(host)