request.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:button-client-python 作者: button 项目源码 文件源码
def request_url(secure, hostname, port, path, query=None):
    '''
        Combines url components into a url passable into the request function.

        Args:
            secure (boolean): Whether or not to use HTTPS.
            hostname (str): The host name for the url.
            port (int): The port number, as an integer.
            path (str): The hierarchical path.
            query (dict): A dict of query parameters.

        Returns:
            (str) A complete url made up of the arguments.
    '''
    encoded_query = urlencode(query) if query else ''
    scheme = 'https' if secure else 'http'
    netloc = '{0}:{1}'.format(hostname, port)

    return urlunsplit((scheme, netloc, path, encoded_query, ''))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号