首页 > 解决方案 > 什么是 urlparse 返回的 scheme://netloc/path;parameters?query#fragment 中的“参数”以及它的使用位置?

问题描述

https://docs.python.org/3/library/urllib.parse.html#url-parsing

将 URL 解析为六个组件,返回一个名为 tuple 的 6 项。这对应于 URL 的一般结构:scheme://netloc/path;parameters?query#fragment。

标签: pythonurl

解决方案


RFC 1808 的第 2.1 节显示了一个示例:

   <scheme>://<net_loc>/<path>;<params>?<query>#<fragment>

each of which, except <scheme>, may be absent from a particular URL.
These components are defined as follows (a complete BNF is provided
in Section 2.2):

   scheme ":"   ::= scheme name, as per Section 2.1 of RFC 1738 [2].

   "//" net_loc ::= network location and login information, as per
                    Section 3.1 of RFC 1738 [2].

   "/" path     ::= URL path, as per Section 3.1 of RFC 1738 [2].

   ";" params   ::= object parameters (e.g., ";type=a" as in
                    Section 3.2.2 of RFC 1738 [2]).

   "?" query    ::= query information, as per Section 3.3 of
                    RFC 1738 [2].

   "#" fragment ::= fragment identifier.

RFC 1738 的第 3.2.2 节处理 FTP URL;我不知道有任何其他使用参数的方案。(不过,直到 5 分钟前,我完全不知道参数部分。)


推荐阅读