本文整理汇总了Python中encodings.idna.IDNAError方法的典型用法代码示例。如果您正苦于以下问题:Python idna.IDNAError方法的具体用法?Python idna.IDNAError怎么用?Python idna.IDNAError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类encodings.idna
的用法示例。
在下文中一共展示了idna.IDNAError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_idna_encoded_host
# 需要导入模块: from encodings import idna [as 别名]
# 或者: from encodings.idna import IDNAError [as 别名]
def _get_idna_encoded_host(host):
import idna
try:
host = idna.encode(host, uts46=True).decode('utf-8')
except idna.IDNAError:
raise UnicodeError
return host
示例2: _get_idna_encoded_host
# 需要导入模块: from encodings import idna [as 别名]
# 或者: from encodings.idna import IDNAError [as 别名]
def _get_idna_encoded_host(host):
try:
from .packages import idna
except ImportError:
# tolerate the possibility of downstream repackagers unvendoring `requests`
# For more information, read: packages/__init__.py
import idna
sys.modules['requests.packages.idna'] = idna
try:
host = idna.encode(host, uts46=True).decode('utf-8')
except idna.IDNAError:
raise UnicodeError
return host
示例3: _get_idna_encoded_host
# 需要导入模块: from encodings import idna [as 别名]
# 或者: from encodings.idna import IDNAError [as 别名]
def _get_idna_encoded_host(host):
from pip._vendor import idna
try:
host = idna.encode(host, uts46=True).decode('utf-8')
except idna.IDNAError:
raise UnicodeError
return host
示例4: _get_idna_encoded_host
# 需要导入模块: from encodings import idna [as 别名]
# 或者: from encodings.idna import IDNAError [as 别名]
def _get_idna_encoded_host(host):
from pipenv.patched.notpip._vendor import idna
try:
host = idna.encode(host, uts46=True).decode('utf-8')
except idna.IDNAError:
raise UnicodeError
return host