本文整理匯總了Python中urlparse.urlparse.urlunparse方法的典型用法代碼示例。如果您正苦於以下問題:Python urlparse.urlunparse方法的具體用法?Python urlparse.urlunparse怎麽用?Python urlparse.urlunparse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類urlparse.urlparse
的用法示例。
在下文中一共展示了urlparse.urlunparse方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: join
# 需要導入模塊: from urlparse import urlparse [as 別名]
# 或者: from urlparse.urlparse import urlunparse [as 別名]
def join(base,url):
join = urlparse.urljoin(base,url)
url = urlparse.urlparse(join)
path = posixpath.normpath(url[2])
return urlparse.urlunparse(
(url.scheme,url.netloc,path,url.params,url.query,url.fragment)
)
示例2: to_urlparse
# 需要導入模塊: from urlparse import urlparse [as 別名]
# 或者: from urlparse.urlparse import urlunparse [as 別名]
def to_urlparse(self):
"Convert to a tuple that can be passed to urlparse.urlunparse()."
# Do not document the return type!
return (
self.__scheme,
self.netloc,
self.__path,
None,
self.query,
self.__fragment
)
#--------------------------------------------------------------------------
示例3: iriToUri
# 需要導入模塊: from urlparse import urlparse [as 別名]
# 或者: from urlparse.urlparse import urlunparse [as 別名]
def iriToUri(self, iri):
import urlparse
parts = urlparse.urlparse(iri.decode('utf-8'))
return urlparse.urlunparse(
part.encode('idna') if parti==1 else self.urlEncodeNonAscii(part.encode('utf-8'))
for parti, part in enumerate(parts)
)