发布时间:2019-09-28 08:39:10编辑:auto阅读(2790)
import urllib
data = urllib.parse.urlencode(params).encode('utf-8')
req = urllib.request.Request(url, data)
req.add_header('Content-Type', "application/x-www-form-urlencoded")
response = urllib.request.urlopen(req)
the_page = response.read().decode('utf-8')
print(the_page)如果不做encode,会直接报错:POST data should be bytes or an iterable of bytes. It cannot be of type str.
如果不做decode,看到的都是assic码
上一篇: python3 教程
下一篇: 关于 Python3 的编码
51565
51145
41660
38420
32905
29877
28598
23559
23492
21837
1986°
2694°
2261°
2186°
2637°
2201°
2949°
4884°
4716°
3357°