Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
enchant.errors.Error:Don';t将ByTestRing传递给pyenchant python_Python_Python 3.x - Fatal编程技术网

enchant.errors.Error:Don';t将ByTestRing传递给pyenchant python

enchant.errors.Error:Don';t将ByTestRing传递给pyenchant python,python,python-3.x,Python,Python 3.x,我正在尝试制作一个程序,在这个程序中,我可以在python中输入一些字符,然后该程序将处理这些字母的所有可能组合。然后将其进行比较,以检查它是否在字典中或是一个单词。如果是,它将被附加到一个列表中,该列表将在最后打印出来。我必须查看如何做某些事情,并且一直做得很好,直到我犯了这个错误。我找不到任何论坛有此消息。有人能帮我,告诉我需要做什么才能让它工作吗?这是我的密码 import itertools import enchant how_many_letters=True letters=[]

我正在尝试制作一个程序,在这个程序中,我可以在python中输入一些字符,然后该程序将处理这些字母的所有可能组合。然后将其进行比较,以检查它是否在字典中或是一个单词。如果是,它将被附加到一个列表中,该列表将在最后打印出来。我必须查看如何做某些事情,并且一直做得很好,直到我犯了这个错误。我找不到任何论坛有此消息。有人能帮我,告诉我需要做什么才能让它工作吗?这是我的密码

import itertools
import enchant
how_many_letters=True
letters=[]
possible_words=[]
d = enchant.Dict("en_US")
print("Welcome to combination letters helper!")
print("Type the word 'stop' to quit entering letters, other wise do it one at a time.")
while how_many_letters==True:
    get_letters=input("Enter the letters you have with not counting spaces:")
    if get_letters=='stop':
        how_many_letters=False
    letters.append(get_letters)
length=len(letters)
length=length-1
del letters[length:]
print(letters)
for i in range(length):
  for subset in itertools.combinations(letters, i):#Subset is the combination thing
    print(subset)
    check=d.check(subset)
    print(check)
    if check==True:
        possible_words.append(check)
print(possible_words)

提前感谢。

您的问题的答案是:

for i in range(1, length + 1):
  for subset in itertools.combinations(letters, i):#Subset is the combination thing
    s = ''.join(subset)
    print(s)
    check=d.check(s)
    print(check)
    if check==True:
        possible_words.append(s)
print(possible_words)
您需要传递一个字符串而不是元组,并且您的范围不起作用


(你可能想看看itertools.permutations(),但我不知道这是否是你想要的。)

我需要长度减去1的原因是删除“停止”,因为这只是告诉循环退出。但它看起来也能在你的代码中做到这一点。所以我想我可以移除它。谢谢你的回复。一件事是字典检查不起作用,因为它给我的组合不是一个单词。根据我看的另一个论坛,我认为我做得对。怎么了?我刚刚编辑了它,因为我看到你用它删除了我之前忽略的停止词。你能给我一些单词的例子吗?我测试了我使用它的应用程序,但它没有包括所有的单词。不好的。然而,这一切都在经历。这是另一个问题。不管怎样,对于字典中的单词,这里有一个例子。我在我使用它的应用程序中测试了它,但它没有包括所有的单词。不好的。然而,这一切都在经历。这是另一个问题。无论如何,对于字典中的单词,这里有一个例子。假设用户输入:a,r,t,y,e,t,f,g,y。例如,它有单词,但它也像rt一样打印,而rt不是一个单词。它也没有说老鼠这个词,这是可能的。所以这里有问题。很抱歉,关于这两条评论,编辑后我将不发布。itertools.permutations()将为您提供“rat”,但运行时间要长得多。至于rt,它可能是realtime的缩写。恐怕你将不得不忍受误报。