1,python 3.X中
(1)
urllib
库 和
urilib2
库合并为
urllib
库
(2)
urllib2.urlopen()
变成
urllib.request.urlopen()
(3)
urllib2.Request()
变成
urllib.request.Request()
2,
urllib.urlencode()
变成
urllib.parse.urlencode()
3,遇到报错:
TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.
解决:
data = urllib.parse.urlencode(values).encode(encoding='UTF8')