本文整理汇总了Python中_socket.gethostbyname_ex方法的典型用法代码示例。如果您正苦于以下问题:Python _socket.gethostbyname_ex方法的具体用法?Python _socket.gethostbyname_ex怎么用?Python _socket.gethostbyname_ex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_socket
的用法示例。
在下文中一共展示了_socket.gethostbyname_ex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gethostbyname_ex
# 需要导入模块: import _socket [as 别名]
# 或者: from _socket import gethostbyname_ex [as 别名]
def gethostbyname_ex(self, *args):
return self.pool.apply(_socket.gethostbyname_ex, args)
示例2: test_gethostbyname_ex
# 需要导入模块: import _socket [as 别名]
# 或者: from _socket import gethostbyname_ex [as 别名]
def test_gethostbyname_ex(self):
'''Tests _socket.gethostbyname_ex'''
#sanity
joe = _socket.gethostbyname_ex("localhost")[2]
self.assertTrue("127.0.0.1" in joe)
joe = _socket.gethostbyname_ex("127.0.0.1")[2]
self.assertTrue("127.0.0.1" in joe)
#negative
self.assertRaises(_socket.gaierror, _socket.gethostbyname_ex, "should never work")
示例3: test_gethostbyname_ex
# 需要导入模块: import _socket [as 别名]
# 或者: from _socket import gethostbyname_ex [as 别名]
def test_gethostbyname_ex(self):
'''Tests _socket.gethostbyname_ex'''
#sanity
joe = _socket.gethostbyname_ex("localhost")[2]
self.assertIn("127.0.0.1" , joe)
joe = _socket.gethostbyname_ex("127.0.0.1")[2]
self.assertIn("127.0.0.1", joe)
#negative
self.assertRaises(_socket.gaierror, _socket.gethostbyname_ex, "should never work")