def LoginAdmin():
# 3 chances seulement ...
LoginTrial = 3
position=0
AdminOK=0
AdminCheck=[]
PassCheck = open('Data_LoginAdmin', 'r')
#lecture des lignes et mise en données les informations mdp et login
for ligne in PassCheck:
print(ligne, end='')
words = ligne.split(":")
AdminCheck.append(words)
print(AdminCheck)
PassCheck.close()
LoginAdminAcces = True
while (((LoginTrial != 0) or (AdminOK == True))):
UserAdminName=input("Identification : ")
if not UserAdminName.isalpha:
LoginTrial = LoginTrial - 1
print("Autentification Échouer essai restant : ", LoginTrial)
elif UserAdminName != AdminCheck[0][0]:
LoginTrial = LoginTrial - 1
print("Autentification Échouer essai restant : ", LoginTrial)
elif UserAdminName == AdminCheck[0][0]:
while (((LoginTrial != 0) or (AdminOK == True))):
UserAdminPass=input("Mot de pass : ")
if not UserAdminName.isalpha:
LoginTrial = LoginTrial - 1
print("Autentification Échouer essai restant : ", LoginTrial)
elif UserAdminPass != AdminCheck[0][1]:
LoginTrial = LoginTrial - 1
print("Autentification Échouer essai restant : ", LoginTrial)
elif UserAdminPass == AdminCheck[0][1]:
LoginAdminAcces = True
AdminOK=True
print(AdminOK)
print("Accès apprové ...")
if LoginTrial == 0:
print("Accès Refusé !!!")
LoginAdminAcces = False
return (LoginAdminAcces)
这是文件Data_LoginAdmin
Admin:AdminPass
如果有人知道为什么它会挽救我的生命......那种......
答案 0 :(得分:0)
不完全确定发生了什么,但这是一个潜在的问题:
UserAdminName == AdminCheck[0][0]
然后输入最后一个elif(可能是正确的密码)AdminOK
设置为True
(可能意味着密码已经过验证)AdminOK
为真,所以while的条件为真我认为while循环应该让AdminOK
为假,这样当密码不正常时你会再次循环。此外,or
应为and
。所以将while循环更改为
while (((LoginTrial != 0) and (AdminOK == False))):
Et“AutentificationÉchouée”car c'est UNE autentification。