社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

使用python检查单词

DelphiProgrammer • 4 年前 • 596 次点击  

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

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
 
596 次点击  
文章 [ 6 ]  |  最新文章 4 年前