鳕鱼天空

This is Mr Wang's Tech Blog.

python 3中,'gbk' codec can't decode byte 0x80 in position 0

错误信息是UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 0: illegal multibyte sequence

其实我是在BeautifulSoup(open('xx.html')) 时候报错的,试了各种编码无效,后来度娘发现,是因为python文件要用二进制打开

soup = BeautifulSoup(open('xx.html', 'rb')) 这样就解决问题了