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, ''))
评论列表
文章目录