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