Topic demand:
1. Enter the user name password
2. Display welcome message after successful authentication
3. Three times after the wrong lock
Username= "Zhangsunan"
Passwd= "123456"
Count=0
With open ("blacklist", Mode= "R", encoding= "UTF8") as F: #打开黑名单
L_list=f.readlines ()
While Count < 3:
Name = input ("Please enter user name")
PWD = input ("Please enter a password")
If name = = Username and pwd = = passwd:
Print ("Welcome login")
Break
If name in L_list: #判断是否在黑名单里
Print ("Your account is locked")
Break
Else
Print ("Bad password")
Count + = 1
if Count = = 3:
Print ("You have entered more than three times, the account is locked")
With open ("blacklist", mode= ' A + ', encoding= "UTF8") as F:
Test = ("\n%s"% name)
F.write (Test)
Print ("User name error")
Insufficient: Only the third input user can be locked
Python login account failed three times, automatic account lockout