小弟用的是 python3.5 ,听说 python3 解决了编码问题
然而
import urllib.request
html = urllib.request.urlopen('http://www.baidu.com').read().decode('utf-8')
print(html)
结果:
Traceback (most recent call last):
File ".\Desktop\work\wearther.py", line 3, in <module>
print(html)
UnicodeEncodeError: 'gbk' codec can't encode character '\xbb' in position 25395: illegal multibyte sequence
这样也不行.decode('utf-8').encode('utf-8')
所以新手求助啊