返回到函数python时未标识名称
这是我的代码:返回到函数python时未标识名称,python,function,Python,Function,这是我的代码: 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 + " ■ " + F
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
word是多个局部变量。如果要在检查中使用它,应将其作为参数传递
def checking(word):
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(word)
return语句真的应该在for循环中吗?它将只处理文件的第一行。而且,检查不会返回任何内容。什么是返回检查应该返回?给定的副本对于这个问题来说有点过分,但我希望它能解决您的问题,并且您可能已经有了更多的问题。