UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 1225: illegal multibyte sequence

f = open(os.path.join(readConfig.proDir, 'testFile', 'emailStyle.txt'))
content = f.read()
f.close()

python 读取 emailStyle.txt 文件时报错 :
UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 1225: illegal multibyte sequence


解决办法:
解决问题很简单,把文件用记事本打开,然后另存为,下面编码选ANSI就好。

 


posted @ 2019-07-30 16:53  蘑菇慢慢  阅读(347)  评论(0)    收藏  举报