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
      

  • 相关阅读:
    软件测试的几种基本方法
    什么是软件测试及软件测试基本原则
    HTTP状态码大全
    jsp 九大内置对象和其作用详解
    快速搞定常用的ES6新特性
    javascript 闭包的学习
    js 中location 的学习
    js 中事件的学习
    js 小菜鸟的学习
    mongodb的返回(3)
  • 原文地址:https://www.cnblogs.com/xuchunlin/p/6971743.html
Copyright © 2011-2022 走看看