python的异常处理

*一、UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xae in position 199: illegal multibyte sequence

在python中以open()打开txt文件之后,想要继续读取文件,解码出现错误。
解决方法
在打开文件时采用hellofile = open(‘D:\delicious\walnut\waffles\hello.txt’,‘r’,encoding=‘UTF-8’)
或者
hellofile = open(‘D:\delicious\walnut\waffles\hello.txt’,‘rb’)

你可能感兴趣的:(python基础)