简体   繁体   English

当单词在单词列表中时打印一些东西

[英]Print something when a word is in a word list

So I am currently trying to build a Caesar encrypted that automatically tries all the possibilities and compares them to a big list of words to see if it is a real word, so some sort of dictionary attack I guess.所以我目前正在尝试构建一个凯撒加密,它会自动尝试所有的可能性,并将它们与一个大的单词列表进行比较,看看它是否是一个真实的单词,所以我猜是某种字典攻击。 I found a list with a lot of German words, and they even are split so that each word is on a new line.我找到了一个包含很多德语单词的列表,它们甚至被拆分,以便每个单词都在一个新的行上。 Currently, I am struggling with comparing the sentence that I currently have with the whole word list.目前,我正在努力将我目前拥有的句子与整个单词列表进行比较。 So that when the program sees that a word in my sentence is also a word in the Word list that it prints out that this is a real word and possible the right sentence.这样当程序看到我的句子中的一个单词也是单词列表中的一个单词时,它会打印出这是一个真实的单词并且可能是正确的句子。 So this is how far I currently am, I have not included the code with which I try all the 26 letters.所以这就是我目前的距离,我没有包括我尝试所有 26 个字母的代码。 Only my way to look through the word list and compares it to a sentence.只有我的方式来查看单词列表并将其与句子进行比较。 Maybe someone can tell me what I am doing wrong and why it doesn't work:也许有人可以告诉我我做错了什么以及为什么它不起作用:


       

No idea why it doesn't work.不知道为什么它不起作用。 I have also tried it with regular expressions but nothing works.我也用正则表达式尝试过,但没有任何效果。 The list is really long (166k Words).这个列表真的很长(166k 字)。

There are /n at the en of each word of the list you created from the file, so the they will never be the same as what they are compared to.您从文件创建的列表的每个单词的 en 都有/n ,因此它们永远不会与它们的比较对象相同。

Remove the newline character before appending (you can, for example, wordlist.append(line.rstrip())在追加之前删除换行符(例如,您可以使用wordlist.append(line.rstrip())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM