#Author:zhanghonglin counter = 0 #肯定真實用戶名和密碼 real_name = "itssky" real_password = "itssoft" #讀取黑名單 f = open ( "black_user" , "r" ) lock_file = f.read() f.close() user_name = input ( "請輸入您的用戶名:" ) #斷定是不是黑名單用戶 for i in range ( 1 ): if user_name == lock_file: print ( "對不起,你的帳戶被鎖定,沒法登錄!" ) exit () else : continue #斷定登錄次數 for i in range ( 3 ): password = input ( "請輸入您的密碼:" ) if password == real_password: print ( "登錄成功!" ) break else : print ( "登錄失敗!" ) counter += 1 if counter == 3 : print ( "對不起!您的錯誤輸入已達三次,即將鎖定帳戶。" ) f = open ( "black_user" , "w" ) f.write( "%s" %user_name) f.close()