Python3 urllib 与 Python2 urllib的变化

2018-09-18 06:42:18来源:博客园 阅读 ()

新老客户大回馈,云服务器低至5折

Infi-chu:

http://www.cnblogs.com/Infi-chu/

Py2.x:

  Urllib库

  Urllin2库

Py3.x:

  Urllib库

变化:

  1. 在Pytho2.x中使用import urllib2——-对应的,在Python3.x中会使用import urllib.request,urllib.error。
  2. 在Pytho2.x中使用import urllib——-对应的,在Python3.x中会使用import urllib.request,urllib.error,urllib.parse。
  3. 在Pytho2.x中使用import urlparse——-对应的,在Python3.x中会使用import urllib.parse。
  4. 在Pytho2.x中使用import urlopen——-对应的,在Python3.x中会使用import urllib.request.urlopen。
  5. 在Pytho2.x中使用import urlencode——-对应的,在Python3.x中会使用import urllib.parse.urlencode。
  6. 在Pytho2.x中使用import urllib.quote——-对应的,在Python3.x中会使用import urllib.request.quote。
  7. 在Pytho2.x中使用cookielib.CookieJar——-对应的,在Python3.x中会使用http.CookieJar。
  8. 在Pytho2.x中使用urllib2.Request——-对应的,在Python3.x中会使用urllib.request.Request。

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:实现统计 android手机 CPU使用率

下一篇:Python学习笔记8——列表、字典、元组