Tag:python3.0 lock User login
# -*- coding:utf-8 -*-#需求模拟用户登录, more than three error locks are not allowed to login Count = 0#realname passwdreal_ username = "test" real_password = "test" #读取黑名单的内容f = open (' Black_user ', ' R ') lock_ File = f.read () F.close () username = input (' Enter user name: ') #判断输入用户是否在黑名单内, if the password is not allowed For i in range (1): if lock_file == username: print (' Sorry, your user is locked, temporarily not allowed! ') exit () else: continue# attempts to enter a password and count the number of inputs For i in range (3): Password = input ("Please enter password:") if Username == Real_Username And password == real_password: print ("Login Successful") break else: print ("Login Failed") count += 1# If you enter the wrong password three times, the user name is prompted to lock, and the user name If count == 3: print ("Sorry, you have entered the wrong number of passwords has reached 3 times, Your user name is locked ") f = open (" Black_user "," W ") f.write ("%s "% Username) f.close ()
This article is from the "Dr Small White" blog, please be sure to keep this source http://metis.blog.51cto.com/1203503/1963377
python3.0 Analog User Login, three error lockout