我想使用在poss = [j.split() for j in [decipher(i, txt) for i in range(1, 26)]]
中创建的变量“I”,但当我试图在第return f"The key is {i} and the deciphered text is{' '.join(k)}."
行中访问它时,它会引发NameError。有没有办法做到这一点而不引起错误
popular = open("C:/Users/NAME/FilesForPyCharm/popular.txt")
words = [line.strip() for line in popular]
poss = [j.split() for j in [decipher(i, txt) for i in range(1, 26)]]
for k in poss:
if set(k).issubset(set(words)):
return f"The key is {i} and the deciphered text is{' '.join(k)}."
您可以将
i
的值与其对应的元素一起保存,然后在对上循环:相关问题 更多 >
编程相关推荐