什么是URL参数?(urlparse结果中位置3处的元素)

2024-05-23 06:51:48 发布

您现在位置:Python中文网/ 问答频道 /正文

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

关于URL结构的Wikipedia条目并没有说明这一点,所以请大家详细说明一下,并给出一些例子?


Tags: 方法文档url条目wikipediaquery结构例子
2条回答

很有趣,这是我第一次遇到他们,发现这个
http://doriantaylor.com/policy/http-url-path-parameter-syntax我也发现了这个 http://tools.ietf.org/html/rfc3986#section-3.3(查询前的最后一段)和 http://www.jtmelton.com/2011/02/02/beware-the-http-path-parameter/

它们很少被使用,我认为它们的目的是将某些属性附加到路径上。。甚至可以控制你想使用哪一个版本的段,但这只是一个预感。。。 不管怎样,谢谢你提出来。

哇。。。我不知道,参见示例:

>>> 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.

相关问题 更多 >

    热门问题