Вопрос

Consensus seems to be that requests is by far the best option for making HTTP requests in Python 2.x. However, in Python 3.x urllib2 has been "split into parts and renamed to urllib.request, urllib.parse, and urllib.error." Has it just been renamed, or has it had parts rewritten making it a decent alternative to requests?

Это было полезно?

Решение

The urllib and urllib2 libraries have been cleaned up for Python 3, moving various disparate parts into a clear package hierarchy. The APIs themselves haven't changed all that much. It's mostly a tightening of the naming conventions.

You only need to compare the Python 2 urllib2 documentation with the urllib.request page for Python 3 (with only exceptions moved to request.error) to see that the basic functionality has not been updated.

requests itself remains the better choice for handling your HTTP client needs in Python 3.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top