How can i import urlparse in python-3? [duplicate]

那年仲夏 提交于 2019-12-03 14:33:37

问题


I would like to use urlparse. But python3.4.1 is not finding the module.

I do import urlparse, but it gives me this error

importError: no 'module' named ulrparse

回答1:


The urlparse in Python 2.7.11 was renamed to urllib.parse in Python 3. So, if you have a code such from urlparse import urljoin, I suggest you change it to from urllib.parse import urljoin




回答2:


As noted in urlparse's documentation:

Note The urlparse module is renamed to urllib.parse in Python 3. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.

I.e., just use urllib.parse instead:

import urllib.parse


来源:https://stackoverflow.com/questions/48072619/how-can-i-import-urlparse-in-python-3

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