我有一个 URL 字符串:
url = "https://foo.bar.com/path/to/aaa.bbb/ccc.ddd;dc_trk_aid=486652617;tfua=;gdpr=;gdpr_consent=?&339286293"
Run Code Online (Sandbox Code Playgroud)
使用 Python 时
url = "https://foo.bar.com/path/to/aaa.bbb/ccc.ddd;dc_trk_aid=486652617;tfua=;gdpr=;gdpr_consent=?&339286293"
Run Code Online (Sandbox Code Playgroud)
使用红宝石时
from urllib.parse import urlparse
url_obj = urlparse(url)
url_obj.path # `path/to/aaa.bbb/ccc.ddd`
Run Code Online (Sandbox Code Playgroud)
我猜python考虑;不是url路径的一部分,哪个是“正确的”?