Python urllib vs httplib? [英] Python urllib vs httplib?

查看:205
本文介绍了Python urllib vs httplib?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么时候会有人使用httplib和何时使用urllib?

When would someone use httplib and when urllib?

有什么区别?

我想我ready urllib使用httplib,我打算创建一个需要发出http请求的应用程序,到目前为止我只在python中使用httplib.HTTPConnection请求,并且阅读urllib我看到我也可以将它用于请求,所以什么是一个或另一个的好处?

I think I ready urllib uses httplib, I am planning to make an app that will need to make http request and so far I only used httplib.HTTPConnection in python for requests, and reading about urllib I see I can use that for request too, so whats the benefit of one or the other?

推荐答案

urllib(特别是urllib2)默认处理很多事情或者有适当的库来执行此操作。例如,urllib2将自动跟踪重定向,您可以使用cookiejar来处理登录脚本。如果您使用的是httplib,这些都是您必须编写代码的所有内容。

urllib (particularly urllib2) handles many things by default or has appropriate libs to do so. For example, urllib2 will follow redirects automatically and you can use cookiejar to handle login scripts. These are all things you'd have to code yourself if you were using httplib.

这篇关于Python urllib vs httplib?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆