本文整理匯總了Python中socket.AddressType方法的典型用法代碼示例。如果您正苦於以下問題:Python socket.AddressType方法的具體用法?Python socket.AddressType怎麽用?Python socket.AddressType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類socket
的用法示例。
在下文中一共展示了socket.AddressType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: socktype_to_enum
# 需要導入模塊: import socket [as 別名]
# 或者: from socket import AddressType [as 別名]
def socktype_to_enum(num):
"""Convert a numeric socket type value to an IntEnum member.
If it's not a known member, return the numeric value itself.
"""
if enum is None:
return num
else: # pragma: no cover
try:
return socket.AddressType(num)
except (ValueError, AttributeError):
return num
示例2: socktype_to_enum
# 需要導入模塊: import socket [as 別名]
# 或者: from socket import AddressType [as 別名]
def socktype_to_enum(num):
"""Convert a numeric socket type value to an IntEnum member.
If it's not a known member, return the numeric value itself.
"""
if enum is None:
return num
try:
return socket.AddressType(num)
except (ValueError, AttributeError):
return num
# --- Process.connections() 'kind' parameter mapping