Day2, into the pit the next day

operation:

 

code show as below:

To be read files stored username and password:
rzf, 123456 
REN, 000000
 
Function as follows:
 
def login_in():
    count = 0
    while True:
        user = []
        psw = []
        for line in open('D:/user.txt', "r", encoding="utf-8-sig"):
            line = line.strip("\n")
            list = line.split(',')
            user.append(list[0])
            psw.append(list[1])
        user1 = INPUT ( ' Enter Username: ' ) .strip ()
         IF user1 in User:
            PSW1 = INPUT ( ' password: ' ) .strip ()
             IF PSW1 in PSW:
                 Print ( ' the Login Succeed! ' )
                count = 0
            else:
                print("password isn't correct,please input again(剩余%s次机会):" %(2-count))
                count+=1
        else:
            print("username isn't correct,please input again(剩余%s次机会):" %(2-count))
            COUNT + =. 1
         IF COUNT ==. 3 :
             Print ( ' Enter the number of times reached the upper limit! ' )
             BREAK 
login_in ()

 

Guess you like

Origin www.cnblogs.com/renzhenfeng/p/11013459.html