Python3 urllib 与 Pyt

发布时间:2019-03-08 20:31:53编辑:auto阅读(3328)

    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。

关键字: