url.parse Python2.7 equivalent

前提是你 提交于 2021-02-10 15:15:26

问题


What is the Python2.7 equivalent to

from urllib.parse import urlparse, parse_qs
parsed_url = urlparse(url)
params = parse_qs(parsed_url.query)

I get

>>> from urllib.parse import urlparse
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named parse

Thanks!


回答1:


In python2 use

from urlparse import urlparse, parse_qs
parsed_url = urlparse(url)
params = parse_qs(parsed_url.query)


来源:https://stackoverflow.com/questions/50638366/url-parse-python2-7-equivalent

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