当前位置: 首页>>代码示例>>Python>>正文


Python parse.urlquote_from_bytes函数代码示例

本文整理汇总了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"))
开发者ID:francois-wellenreiter,项目名称:cpython,代码行数:10,代码来源:pathlib.py

示例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')))
开发者ID:mrbean-bremen,项目名称:pyfakefs,代码行数:15,代码来源:fake_pathlib.py

示例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)
开发者ID:python,项目名称:cpython,代码行数:5,代码来源:pathlib.py


注:本文中的urllib.parse.urlquote_from_bytes函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。