Py学习  »  Python

使用python检查单词

DelphiProgrammer • 4 年前 • 589 次点击  

我被一个简单的问题困住了。我有一本英语单词词典,还有一个要检查的文本样本。我必须对照字典核对样本中的每个单词,我使用的代码是错误的。

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

唯一的问题是,当它通过循环时,它会打印出每个单词,而不仅仅是拼写错误的单词。有人能解释一下并提供解决方案吗?非常感谢!

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/43411
 
589 次点击  
文章 [ 6 ]  |  最新文章 4 年前