记录一下 python2.x 和 python3.x 中urllib库的变化情况

Py2.x:

  • Urllib
  • Urllin2

Py3.x:

  • Urllib

变化:

  • 在Pytho2.x中使用import urllib2——-对应的,在Python3.x中会使用import urllib.requesturllib.error
  • 在Pytho2.x中使用import urllib——-对应的,在Python3.x中会使用import urllib.requesturllib.errorurllib.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.csdn.net/duxu24/article/details/77414298

猜你喜欢

转载自blog.csdn.net/wunai006/article/details/80559449