Py2.x:
Urllib库
Urllin2库
Py3.x:
Urllib库
变化:
在Pytho2.x中使用import urllib2——-对应的,在Python3.x中会使用import urllib.request,urllib.error。
在Pytho2.x中使用import urllib——-对应的,在Python3.x中会使用import urllib.request,urllib.error,urllib.parse。
在Pytho2.x中使用import urlparse——-对应的,在Python3.x中会使用import urllib.parse。
在Pytho2.x中使用import urlopen——-对应的,在Python3.x中会使用import urllib.request.urlopen。
在Pytho2.x中使用import urlencode——-对应的,在Python3.x中会使用import urllib.parse.urlencode。
在Pytho2.x中使用import urllib.quote——-对应的,在Python3.x中会使用import urllib.request.quote。
在Pytho2.x中使用cookielib.CookieJar——-对应的,在Python3.x中会使用http.CookieJar。
在Pytho2.x中使用urllib2.Request——-对应的,在Python3.x中会使用urllib.request.Request。
原文:https://blog.youkuaiyun.com/duxu24/article/details/77414298
本文详细介绍了从Python 2.x到3.x版本中,网络请求库如Urllib、Urllib2等的变化及对应更新方式,包括Request、Error、Parse等模块的迁移策略,以及CookieJar和Quote等函数的使用调整。
8202

被折叠的 条评论
为什么被折叠?



