What are the URL parameters? (element at position #3 in urlparse result)

后端 未结 2 1291
忘掉有多难
忘掉有多难 2020-12-08 09:37

I\'ve taken a look to urlparse.urlparse method documentation and I\'m a little bit confused about what is the parameters part (not to be confused w

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 10:10

    Wow... I was not aware of that, see example:

    >>> urlparse.urlparse("http://some.page.pl/nothing.py;someparam=some;otherparam=other?query1=val1&query2=val2#frag")
    ParseResult(scheme='http', netloc='some.page.pl', path='/nothing.py', params='someparam=some;otherparam=other', query='query1=val1&query2=val2', fragment='frag')
    

    And help(urlparse.urlparse):

    Help on function urlparse in module urlparse:
    
    urlparse(url, scheme='', allow_fragments=True)
        Parse a URL into 6 components:
        :///;?#
        Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
        Note that we don't break the components up in smaller bits
        (e.g. netloc is a single string) and we don't expand % escapes.
    

提交回复
热议问题