Login Requirements:
1, user input login account, password, login successful display welcome User login Interface
2, the user can try to log in three times, three login failed, will lock the user, and output to the new file.
Count = 0while count < 3 : file1 = open (" Accounts.txt ", " R ") data1 = file1.read (). Strip (). Split () username = input ("please input your username>>>> ") password = input ("please input your password>>>> ") if username == data1[0] and password == Data1[1]: print ("Welcom to %s login" % username) break; elif username == data1[2] and password == data1[3]: print ("Welcom to %s login" % username) break; elif username == data1[4] and password == data1[5]: print ("Welcom to %s login" % username) break; else: print ("User %s login is failure please try again" % username) count = count + 1else: file2 = open ("Lock_userlist.txt", "W") file2.write (username) print ("you have try 3 times your %s is locked\n" % Username
Accounts.txt
Test: Login Successful
Test: Login Failed
Python impersonate three user logins, login failed to lock account and write to file