【发布时间】:2019-12-31 22:06:17
【问题描述】:
这是我的代码:
def checking():
response2 = requests.get('https://www.nitrxgen.net/md5db/' + str(word[1])).text
if response2:
print(Fore.GREEN + "[" + Fore.WHITE + strftime("%H:%M:%S")+ Fore.GREEN + "]" + Fore.WHITE + " |" + Fore.GREEN + " ■ " + Fore.WHITE +
"Hash Found: " + Fore.GREEN + response2 + Style.RESET_ALL + "\n", end='')
else:
print(Fore.RED + "[" + Fore.WHITE + strftime("%H:%M:%S")+ Fore.RED + "]" + Fore.WHITE + " |" + Fore.RED + " ■ " + Fore.WHITE +
"Hash Not Found" + Style.RESET_ALL + "\n", end='')
def Mutiple():
Tk().withdraw()
filename = askopenfilename(title='Choose a File', filetypes=[("Text Files", "*.txt")])
clear = lambda: os.system('cls')
clear()
with open(filename, "r", encoding="utf8") as file:
for line in file:
word = line.strip()
word = word.split(":")
return checking()
错误码是
Traceback (most recent call last):
File "C:\Users\tosun\OneDrive\Desktop\Hashkiller\Hashkiller.py", line 111, in <module>
Mutiple()
File "C:\Users\tosun\OneDrive\Desktop\Hashkiller\Hashkiller.py", line 40, in Mutiple
return checking()
File "C:\Users\tosun\OneDrive\Desktop\Hashkiller\Hashkiller.py", line 18, in checking
response2 = requests.get('https://www.nitrxgen.net/md5db/' + str(word[1])).text
NameError: name 'word' is not defined
【问题讨论】:
-
return语句真的应该在for循环内吗?它只会处理文件的第一行。 -
另外,
checking()不会返回任何内容。return checking()应该返回什么? -
给定的“重复”对于这个问题来说有点矫枉过正,但我希望它能解决您的问题,并且您可能还会遇到更多问题。