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

╄→гoц情女王★ 提交于 2019-11-27 11:54:43

问题


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 with the more familiar query part, that is what goes after the question mark and before the fragment part).

Wikipedia entry on URL's structure doesn't say anything about that, so could please anybody elaborate a little bit on this and possibly give some examples?


回答1:


fascinating, this is the first time I've encounter them, found this
http://doriantaylor.com/policy/http-url-path-parameter-syntax I also found this http://tools.ietf.org/html/rfc3986#section-3.3 (last paragraph before query) and this http://www.jtmelton.com/2011/02/02/beware-the-http-path-parameter/

their rarely used, I think their meant to attach certain properties to paths .. maybe even control which version of segment you want to use, but this is just a hunch ... either way thank you, for bringing it up.




回答2:


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


来源:https://stackoverflow.com/questions/10988614/what-are-the-url-parameters-element-at-position-3-in-urlparse-result

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!