Pythonimport urllib2 ImportError: No module named 'urllib2'

mac2022-06-30  99

python3

import urllib2 import urllib2 ImportError: No module named 'urllib2'

python3.3里面,用urllib.request 代替 urllib2, 所以可以这样兼容python2 和python3

import sys if sys.version > '3': import urllib.request as urllib2 else: import urllib2

转载于:https://www.cnblogs.com/vercont/p/10210181.html

最新回复(0)