本文整理汇总了Python中urllib.localhost方法的典型用法代码示例。如果您正苦于以下问题:Python urllib.localhost方法的具体用法?Python urllib.localhost怎么用?Python urllib.localhost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urllib
的用法示例。
在下文中一共展示了urllib.localhost方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_names
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import localhost [as 别名]
def get_names(self):
if FileHandler.names is None:
FileHandler.names = (socket.gethostbyname('localhost'),
socket.gethostbyname(socket.gethostname()))
return FileHandler.names
# not entirely sure what the rules are here
示例2: file_open
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import localhost [as 别名]
def file_open(self, req):
url = req.get_selector()
if url[:2] == '//' and url[2:3] != '/' and (req.host and
req.host != 'localhost'):
req.type = 'ftp'
return self.parent.open(req)
else:
return self.open_local_file(req)
# names for the localhost
示例3: get_names
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import localhost [as 别名]
def get_names(self):
if FileHandler.names is None:
try:
FileHandler.names = tuple(
socket.gethostbyname_ex('localhost')[2] +
socket.gethostbyname_ex(socket.gethostname())[2])
except socket.gaierror:
FileHandler.names = (socket.gethostbyname('localhost'),)
return FileHandler.names
# not entirely sure what the rules are here
示例4: get_names
# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import localhost [as 别名]
def get_names(self):
if FileHandler.names is None:
try:
FileHandler.names = (socket.gethostbyname('localhost'),
socket.gethostbyname(socket.gethostname()))
except socket.gaierror:
FileHandler.names = (socket.gethostbyname('localhost'),)
return FileHandler.names
# not entirely sure what the rules are here