我正在建立一个ID确认系统,用户有3次尝试键入正确的ID,如果没有,系统将退出。我的问题是,当用户在最后一次输入正确的ID时,第三次输入正确的ID,当代码正确时,语句写的ID是正确的,第二行显示他,他输入了太多的尝试,系统正在退出。如何修复错误? 我该如何修复,当用户在3/3的尝试中键入正确的ID时,系统会说,correct we can break the if语句。 我的代码:
checkas = True
Attempts = 3
CurrentAttemp = 0
KickForBadCode = sys.exit
while checkas:
CurrentAttemp += 1
IDConfirm = input("* [3NEMATIX]: {} Please confirm Your ID CODE... Attempt! {}/{} ".format(Vartotojo_Vardas, CurrentAttemp, Attempts))
with open (DuomenuBaz, mode = 'r', encoding = 'utf-8') as Confirm:
for line in Confirm:
if "Vardas: "+Vartotojo_Vardas + " Password: " + Vartotojo_Pass + " ID: " + IDConfirm in line.strip():
print("Correct!")
Confirm.close()
checkas = False
break
elif "Vardas: "+Vartotojo_Vardas + " Password: " + Vartotojo_Pass + " ID: " + IDConfirm in line.strip() and CurrentAttemp > 2:
clear()
print("Correct!")
Confirm.close()
checkas = False
break
elif CurrentAttemp >2:
clear()
print("~ You have been kicked for too many attempts!")
checkas = False
sys.exit
只有当
CurrentAttemp
大于>
时,才需要exit
。如果Vartotojo_Pass
在<=
到Attempts
中是正确的尝试更换此部件:
有了这个:
我修复了它,它有太多的if语句,导致脚本每次都重新bool,脚本无法正常工作。问题只是if语句
相关问题 更多 >
编程相关推荐