Python requests.compat 模块,quote() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用requests.compat.quote()

项目:steemprojects.com    作者:noisy    | 项目源码 | 文件源码
def quote_plus(s, safe=''):
    """Quote the query fragment of a URL; replacing ' ' with '+'"""
    if ' ' in s:
        s = quote(s, safe + ' ')
        return s.replace(' ', '+')
    return quote(s, safe)
项目:apimas    作者:grnet    | 项目源码 | 文件源码
def format_endpoint(self, resource_id):
        """
        This method concatenates the resource's endpoint with a specified
        identifier.

        Example: endpoint/<pk>/
        """
        if isinstance(resource_id, unicode):
            resource_id = resource_id.encode("utf-8")
        return urljoin(self.endpoint, quote(
            str(resource_id))) + TRAILING_SLASH
项目:Codeforces-Sublime-Plugin    作者:karunk    | 项目源码 | 文件源码
def test_get_auth_from_url(self):
        """Ensures that username and password in well-encoded URI as per
        RFC 3986 are correclty extracted."""
        from requests.utils import get_auth_from_url
        from requests.compat import quote
        percent_encoding_test_chars = "%!*'();:@&=+$,/?#[] "
        url_address = "request.com/url.html#test"
        url = "http://" + quote(
            percent_encoding_test_chars, '') + ':' + quote(
            percent_encoding_test_chars, '') + '@' + url_address
        (username, password) = get_auth_from_url(url)
        assert username == percent_encoding_test_chars
        assert password == percent_encoding_test_chars