URI = scheme:[//authority]path[?query][#fragment] authority = [userinfo@]host[:port] userinfo = [user_name:password]
scheme://netloc/path;params?query#fragment scheme:在“://”前面,代表协议。 netloc:在第一个“/”前面,代表域名。 path:在“/”后面,代表访问路径。 params:在分号后面,代表参数。 query:在问号后面,代表查询条件,一般用作GET类型的URL。 fragment:在#后面,代表锚点,用于直接指定页面内部下拉距离。# 3. 实例
## 3.1 代码实现
# -*- coding = utf-8 -*-
# @Time : 2021/10/6 1:13
# @Author : LIUYU
# @File : test_urlib_parse_urlparser.py
# @Software : PyCharm
import urllib.parse
url = 'https://blog.csdn.net/m0_62298204?spm=1001.2101.3001.5343'
# urllib.parse.urlparse
result = urllib.parse.urlparse(url)
print(result.scheme)
print(result.netloc)
print(result.path)
if result.params:
print(result.params)
else:
print('There's no params in this URL.')
## 3.2 运行结果



