zoukankan      html  css  js  c++  java
  • Python2.X和Python3.X中的urllib区别

    Urllib是Python提供的一个用于操作URL的模块,在Python2.X中,有Urllib库,也有Urllib2库,在Python3.X中Urllib2合并到了Urllib中,我们爬取网页的时候,经常需要用到这个库。下面总结了Urllib相关模块中从Python2.X到Python3.X的常见的一些变动。
    

      

    在Python2.X中使用import urllib2——对应的,在Python3.X中会使用import urllib.request,urllib.error。


    在Python2.X中使用import urllib——对应的,在Python3.X中会使用import urllib.request,urllib.error,urllib.parse。


    在Python2.X中使用import urlparse——对应的,在Python3.X中会使用import urllib.parse。


    在Python2.X中使用import urllib2——对应的,在Python3.X中会使用import urllib.request,urllib.error。


    在Python2.X中使用urllib2.urlopen——对应的,在Python3.X中会使用urllib.request.urlopen。


    在Python2.X中使用urllib.urlencode——对应的,在Python3.X中会使用urllib.parse.urlencode。


    在Python2.X中使用urllib.quote——对应的,在Python3.X中会使用urllib.request.quote。


    在Python2.X中使用cookielib.CookieJar——对应的,在Python3.X中会使用http.CookieJar。


    在Python2.X中使用urllib2.Request——对应的,在Python3.X中会使用urllib.request.Request
      

  • 相关阅读:
    Bayer RGB和RGB Raw
    YUV像素和ycbcr
    像素,分辨率,PPI(像素密度),BPP 扫盲
    Shadow Register 是什么?
    ITU-R BT.656 协议
    octopress的一些总结
    0ull 是什么意思?
    attribute section的用法
    常见指令集架构
    Centos 用户组管理
  • 原文地址:https://www.cnblogs.com/xuchunlin/p/6971743.html
Copyright © 2011-2022 走看看