我被一个简单的问题困住了。我有一本英语单词词典,还有一个要检查的文本样本。我必须对照字典核对样本中的每个单词,我使用的代码是错误的。
for word in checkList: # iterates through every word in the sample
if word not in refDict: # checks if word is not in the dictionary
print word # just to see if it's recognizing misspelled words
唯一的问题是,当它通过循环时,它会打印出每个单词,而不仅仅是拼写错误的单词。有人能解释一下并提供解决方案吗?非常感谢!