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')