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


Python URLObject.from_iri方法代码示例

本文整理汇总了Python中urlobject.URLObject.from_iri方法的典型用法代码示例。如果您正苦于以下问题:Python URLObject.from_iri方法的具体用法?Python URLObject.from_iri怎么用?Python URLObject.from_iri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在urlobject.URLObject的用法示例。


在下文中一共展示了URLObject.from_iri方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import from_iri [as 别名]
    def __init__(self):
        """
        Initialize the Request. All parameters are set as public attributes
        with the same name.

        :param str method: (or bytes) the method to use
        :param str url: (or bytes) the URL to fetch. This can have non-ASCII
            characters, and they will be interpreted as an IRI.
        :param dict headers: the headers to send with the request.
            keys and values must be bytes.
        :param bytes data: the request body to send
        :param int timeout: time to way before giving up. None means
            no timeout
        """
        self.url = URLObject.from_iri(self.url)
        if self.headers is not None:
            for k,v in self.headers.items():
                if type(k) is not bytes:
                    raise TypeError("headers key {key!r} is not bytes".format(key=k))
                elif type(v) is not bytes:
                    raise TypeError("headers value {value!r} is not bytes".format(value=v))
开发者ID:radix,项目名称:effreq,代码行数:23,代码来源:intent.py

示例2: test_quote_other_special_characters

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import from_iri [as 别名]
 def test_quote_other_special_characters(self):
     assert (URLObject.from_iri(u('https://example.com/foo bar/')) ==
         'https://example.com/foo%20bar/')
开发者ID:MisterRios,项目名称:urlobject,代码行数:5,代码来源:urlobject_test.py

示例3: test_quoted_iri

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import from_iri [as 别名]
 def test_quoted_iri(self):
     """
     If an IRI already has some quoted characters, they will be maintained as is.
     """
     assert (URLObject.from_iri(u('https://example.com/foo%20b\xe5r/')) ==
         'https://example.com/foo%20b%C3%A5r/')
开发者ID:MisterRios,项目名称:urlobject,代码行数:8,代码来源:urlobject_test.py

示例4: test_path_params

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import from_iri [as 别名]
 def test_path_params(self):
     assert (URLObject.from_iri(u('https://example.com/foo;p\xe5rameter')) ==
             'https://example.com/foo;p%C3%A5rameter')
开发者ID:MisterRios,项目名称:urlobject,代码行数:5,代码来源:urlobject_test.py

示例5: test_encode_fragment

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import from_iri [as 别名]
 def test_encode_fragment(self):
     assert (URLObject.from_iri(u('https://example.com/#fr\xe5gment')) ==
             'https://example.com/#fr%C3%A5gment')
开发者ID:MisterRios,项目名称:urlobject,代码行数:5,代码来源:urlobject_test.py

示例6: test_encode_query

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import from_iri [as 别名]
 def test_encode_query(self):
     assert (URLObject.from_iri(u('https://example.com/?k\xe9y=v\xe5l&key2=val2')) ==
             'https://example.com/?k%C3%A9y=v%C3%A5l&key2=val2')
开发者ID:MisterRios,项目名称:urlobject,代码行数:5,代码来源:urlobject_test.py

示例7: test_encode_path

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import from_iri [as 别名]
 def test_encode_path(self):
     assert (URLObject.from_iri(u('https://example.com/p\xe5th/path2')) ==
             'https://example.com/p%C3%A5th/path2')
开发者ID:MisterRios,项目名称:urlobject,代码行数:5,代码来源:urlobject_test.py

示例8: test_port_maintained

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import from_iri [as 别名]
 def test_port_maintained(self):
     assert (URLObject.from_iri(u('https://\xe9xample.com:80/')) ==
             'https://xn--xample-9ua.com:80/')
开发者ID:MisterRios,项目名称:urlobject,代码行数:5,代码来源:urlobject_test.py

示例9: test_encode_hostname_idna

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import from_iri [as 别名]
 def test_encode_hostname_idna(self):
     assert (URLObject.from_iri(u('https://\xe9xample.com/')) ==
             'https://xn--xample-9ua.com/')
开发者ID:MisterRios,项目名称:urlobject,代码行数:5,代码来源:urlobject_test.py

示例10: request_intent

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import from_iri [as 别名]
def request_intent(method, url, headers=None, **kwargs):
    url = URLObject.from_iri(url)
    return Request(method, url, headers=headers, **kwargs)
开发者ID:radix,项目名称:fxhttp,代码行数:5,代码来源:_intent.py


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