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