本文整理汇总了Python中urllib.parse.urlquote_from_bytes函数的典型用法代码示例。如果您正苦于以下问题:Python urlquote_from_bytes函数的具体用法?Python urlquote_from_bytes怎么用?Python urlquote_from_bytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了urlquote_from_bytes函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_uri
def make_uri(self, path):
# Under Windows, file URIs use the UTF-8 encoding.
drive = path.drive
if len(drive) == 2 and drive[1] == ":":
# It's a path on a local drive => 'file:///c:/a/b'
rest = path.as_posix()[2:].lstrip("/")
return "file:///%s/%s" % (drive, urlquote_from_bytes(rest.encode("utf-8")))
else:
# It's a path on a network drive => 'file://host/share/a/b'
return "file:" + urlquote_from_bytes(path.as_posix().encode("utf-8"))
示例2: make_uri
def make_uri(self, path):
"""Return a file URI for the given path"""
# Under Windows, file URIs use the UTF-8 encoding.
# original version, not faked
drive = path.drive
if len(drive) == 2 and drive[1] == ':':
# It's a path on a local drive => 'file:///c:/a/b'
rest = path.as_posix()[2:].lstrip('/')
return 'file:///%s/%s' % (
drive, urlquote_from_bytes(rest.encode('utf-8')))
else:
# It's a path on a network drive => 'file://host/share/a/b'
return ('file:' +
urlquote_from_bytes(path.as_posix().encode('utf-8')))
示例3: make_uri
def make_uri(self, path):
# We represent the path using the local filesystem encoding,
# for portability to other applications.
bpath = bytes(path)
return 'file://' + urlquote_from_bytes(bpath)