是否有我们可以下载的用于 python 的 urllib2 库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16597865/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 23:07:09  来源:igfitidea点击:

Is there a library for urllib2 for python which we can download?

pythonurllib2

提问by Josh

I need to use urllib2 with BeautifulSoup. I found the download file for BeautifulSoup and installed it, however, I couldn't find any download files for urllib2, is there another way to intall that module?

我需要将 urllib2 与 BeautifulSoup 一起使用。我找到了 BeautifulSoup 的下载文件并安装了它,但是,我找不到 urllib2 的任何下载文件,还有其他方法可以安装该模块吗?

回答by dav1d

The module comes with Python, simply import it:

该模块随 Python 一起提供,只需导入即可:

import urllib2

If you're using Python3, the urllibwas replaced by urllib.request. The Urllib PEP (Python3): http://www.python.org/dev/peps/pep-3108/#urllib-package.

如果您使用的是 Python3,则将urllib.requesturllib替换。Urllib PEP (Python3):http://www.python.org/dev/peps/pep-3108/#urllib-package 。