如何在python-3中导入urlparse? [重复]

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在python-3中导入urlparse? [重复]相关的知识,希望对你有一定的参考价值。

这个问题在这里已有答案:

我想用urlparse。但是python3.4.1没有找到模块。

我做import urlparse,但它给了我这个错误

importError: no 'module' named ulrparse
答案

Python 2.7.11中的urlparse在Python 3中被重命名为urllib.parse。所以,如果你有一个像from urlparse import urljoin这样的代码,我建议你把它改成from urllib.parse import urljoin

另一答案

urlparse's documentation所述:

注意urlparse模块在Python 3中重命名为urllib.parse.2to3工具在将源代码转换为Python 3时会自动调整导入。

即,只需使用urllib.parse

import urllib.parse

以上是关于如何在python-3中导入urlparse? [重复]的主要内容,如果未能解决你的问题,请参考以下文章

无法在 Python 3.5.2 中导入 itertools

无法在python 3中导入字符串

在 Python 3.5 中导入 bs4

在 macOS 10.14.6 上的 Python 3.7.4 中导入 ssl 时出错

在 Python 3 中导入模块时出现 AttributeError

安装的 PILLOW 模块未识别为在 Python 3 中导入