47

我查看了urlparse.urlparse方法文档,我对这部分是什么有点困惑parameters(不要与更熟悉的query部分混淆,即问号之后和片段部分之前的部分)。

关于 URL 结构的 Wikipedia 条目没有说明任何内容,所以请任何人对此进行详细说明并可能给出一些示例?

4

2 回答 2

32

哇...我没有意识到这一点,请参见示例:

>>> 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')

和帮助(urlparse.urlparse):

Help on function urlparse in module urlparse:

urlparse(url, scheme='', allow_fragments=True)
    Parse a URL into 6 components:
    <scheme>://<netloc>/<path>;<params>?<query>#<fragment>
    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.
于 2012-06-11T23:31:24.677 回答
26

令人着迷,这是我第一次遇到它们,找到了这个
http://doriantaylor.com/policy/http-url-path-parameter-syntax我也找到了这个 https://www.rfc-editor.org/ rfc/rfc3986#section-3.3(查询前的最后一段)和这个 http://www.jtmelton.com/2011/02/02/beware-the-http-path-parameter/

他们很少使用,我认为他们的意思是将某些属性附加到路径..甚至可以控制您要使用的段版本,但这只是一种预感......无论哪种方式,谢谢你提出来。

于 2012-06-11T23:30:50.517 回答