我想在Python中创建一个密码猜测器,所以我想我可以在下面的代码中使用该方法。我是Python的新手,所以我不知道自己在做什么。
在代码中,我有一个包含109538个单词的文件,从字典读取,现在是一个列表。
要使代码生效,需要将范围设置为列表" DictionaryWords",它包含字典中的所有单词作为列表。
#I made this to open file and read it
dictfile = open('c:/ScienceFairDictionaryFolder/wordsEn.txt', 'r')
DictionaryWords = dictfile.readlines()
Password = "Cat"
for x in range(0, 109538):
if x is Password:
print(x, "Found it!")
else:
print("Nope! Not here!")
是否可以,或者范围是否仅适用于由整数组成的列表?