python作業:編寫登陸介面
阿新 • • 發佈:2019-02-10
#!/usr/bin/env python # Robin # 作業二:編寫登陸介面 # 輸入使用者名稱密碼 # 認證成功後顯示歡迎資訊 # 輸錯三次後鎖定 username = "robin" password = "12345" confirm_the_lock="" time = 0 while time != 3: input_username = input("username:") input_password = input("password:") if input_username == username and input_password == password: print("Login Success!") break else: time += 1 if time == 3: confirm_the_lock = "Your account has been locked!" error = ''' error: passwordWrong(There are {residue_degree} chances left) {lock} '''.format(residue_degree=3 - time,lock=confirm_the_lock) print(error)