本文整理匯總了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)