User login inspection----no optimization, God can help optimize optimization

import json
 # ##Check if the entered user is locked 
def UserLogin():
    UserFile = open("UserFile.text", "rb")
    UserInput = input( " Please enter the account number: " )
    UserRead = json.load(UserFile)
     for UserRead_ in UserRead:
         if UserRead_[ " UserID " ] == UserInput:
             print ( " [%s] This user is also locked, please contact the administrator! " % UserInput)
            exit()
        else:
            UserPass(UserInput)
    UserFile.close()
lock_List = []
 # ##User locks read files 
def Userlock(lock,UserInput):
     for lock_list in lock:
        lock_List.append(lock_list)
    UserLock(lock_List,UserInput)
# ##User Lock Modification 
def UserLock(lock_List,UserInput):
    lock_List.append({"UserID":UserInput})
    UserLock__ = open("UserFile.text","w")
    UserLock_ = json.dump(lock_List,UserLock__)
     print ( " Your [%s] account has been frozen, please contact the administrator!!! " % UserInput)
    UserLock__.close()
# ##Check whether the account entered by the user exists, enter the password if it exists, and prompt the user 
def UserPass(UserInput) if it does not exist:
    UserPassRead = open("UserReadFile.text","rb")
    User_PassRead = json.load(UserPassRead)
    count_1 = 0
    for Userread_ in User_PassRead:
        count_1 += 1
        if Userread_["UserID"] == UserInput :
            count_ = 0
            while count_ < 3:
                count_ += 1 
                User_Pass = input( " Please enter your password: " )
                 if Userread_[ " UserPass " ] == User_Pass:
                     print ( " [%s] Welcome " % UserInput)
                    exit()
                elif count_ < 3 :
                     print ( " Wrong password, please re-enter!! You have [%s] left " % (3 - count_))
                 elif count_ == 3 :
                    k = open("UserFile.text","rb")
                    lock=json.load(k)
                    Userlock(lock,UserInput)
                    k.close()
                    exit()
        elif len(Userread_) == count_1:
             print ( " [%s] The account has not been registered " % UserInput)
             print ( " You can go to register (a)/re-enter account (b) " )
            Input_ = input("a/b:")
            if Input_ == "a":
                exit()
            else:
                UserLogin ()
    UserPassRead.close()
UserLogin ()
[{"UserID": "123"}, {"UserID": "122"}, {"UserID": "121"}, {"UserID": "120"}, {"UserID": "124"}, {"UserID": "1341"}]
[{"UserID": "1341", "UserPass": "13421731041"},{"UserID": "13421731047", "UserPass": "13421731041"}]

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325075473&siteId=291194637