>>> bayes.spamTest()
Traceback (most recent call last):
File "<pyshell#19>", line 1, in <module>
bayes.spamTest()
File "E:\AI\FirstPythonProj\bayes.py", line 96, in spamTest
wordList = textParse(open('MachineLearningSourceCode/Ch04/email/ham/%d.txt' % i).read())
Traceback (most recent call last):
File "<pyshell#19>", line 1, in <module>
bayes.spamTest()
File "E:\AI\FirstPythonProj\bayes.py", line 96, in spamTest
wordList = textParse(open('MachineLearningSourceCode/Ch04/email/ham/%d.txt' % i).read())
UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 199: illegal multibyte sequence
用的Python 3.6.4 Shell运行,打开Text文档没有发现很明显的非法字符,对应语句改成‘utf-8’,继续其它地方报错。
wordList = textParse(open('MachineLearningSourceCode/Ch04/email/ham/%d.txt' % i,encoding ='utf-8').read())
>>> bayes.spamTest()
Traceback (most recent call last):
File "<pyshell#21>", line 1, in <module>
bayes.spamTest()
File "E:\AI\FirstPythonProj\bayes.py", line 96, in spamTest<