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