from urllib import request
resp = request.urlopen("http://www.baidu.com")
print(resp.read().decode('utf-8'))
报错是这样的
Traceback (most recent call last):
File "aa.py", line 6, in <module>
print(resp.read().decode('utf-8'))
UnicodeEncodeError: 'gbk' codec can't encode character '\xbb' in position 26740:
illegal multibyte sequence
这个是回事,说什么gbk编码器不能识别(\xbb)这个乱码,要如何解决呢,
相关分类