python3与 python2 urllib模块区别
Py2.x:
Urllib库Urllin2库
Py3.x:
Urllib库
变化:
- 在Pytho2.x中使用
import urllib2——-对应的,在Python3.x中会使用import urllib.request,urllib.error。 - 在Pytho2.x中使用
import urllib——-对应的,在Python3.x中会使用import urllib.request,urllib.error,urllib.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。

浙公网安备 33010602011771号