‘gbk‘ codec can‘t decode byte 0xaf in position 12: illegal multibyte sequence

‘gbk’ codec can’t decode byte 0xaf in position 12: illegal multibyte sequence

#报错
stopkey = [w.strip() for w in codecs.open('stopWord.txt', 'r').readlines()]

添加
,encoding="utf-8"

stopkey = [w.strip() for w in codecs.open('stopWord.txt', 'r',encoding="utf-8").readlines()]
    
上一篇:python 文件的读写


下一篇:文件处理中readline(n)与readlines(n)括号中的参数代表的意义