对Python3使用urllib2

2024-03-28 09:19:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在python3中使用urllib2,但我不认为它以这样的名称可用。在

我使用urllib.request,有没有其他方法可以使用urllib2?


Tags: 方法名称requesturllib2urllibpython3
3条回答

Python 3中的urllib2被拆分为several modules

The urllib2 module has been split across several modules in Python 3 named urllib.request and urllib.error. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.

^{}是用于发出HTTP请求的内容。在

或者,开源的Requests库为在python2和python3中发出HTTP请求提供了一个更简单、更干净的API。在

The urllib2 module has been split across several modules in Python 3.0 named urllib.request and urllib.error. The 2to3 tool will automatically adapt imports when converting your sources to 3

您应该尝试一下Requests;它适用于python2.6-3.3。好吧。在

相关问题 更多 >