import urllib.request
res = urllib.request.urlopen('http://www.tantengvip.com').read()
html = res.decode('utf8')
print(html)
但是报错
D:\learn-python>python zhua_tantengvip.py
Traceback (most recent call last):
File "zhua_tantengvip.py", line 5, in <module>
print(html)
UnicodeEncodeError: 'gbk' codec can't encode character '\xe6' in position 49945:
illegal multibyte sequence
我上网查了,编码问题,说了很多解决办法,都没用。我是python3环境,在windows的cmd运行的代码。