因此,基本上我有一个文本文件中的单词列表,我希望能够搜索匹配的单词时用户输入一个检查拼写,这是到目前为止,我有什么。在python中搜索文本文件中的输入词
f = open('words.txt', 'r')
wordCheck = input("please enter the word you would like to check the spelling of: ")
for line in f:
if 'wordCheck' == line:
print ('That is the correct spelling for '+wordCheck)
else:
print (wordCheck+ " is not in our dictionary")
break
当我输入一个单词时,我只是马上得到else语句,我不认为它甚至通过文本文件读取。 我应该使用while循环吗?
while wordCheck != line in f
我是新来的蟒蛇,最终我希望用户能够输入的词,如果拼写不正确,程序应该打印出匹配的单词列表(字母或以上的75%匹配)。
任何帮助,将不胜感激
为什么你的代码中有'break'? – neelsg