문제

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