標籤:lease 使用 http 代碼 log 退出 style images lock
需求:
- 可以支援多個使用者登入 (提示,通過列表存多個賬戶資訊)
- 使用者3次認證失敗後,退出程式,再次啟動程式嘗試登入時,還是鎖定狀態(提示:需把使用者鎖定的狀態存到檔案裡)
流程圖:
代碼:
1 div={ 2 ‘list1‘:{‘password‘:‘123456‘}, 3 ‘list2‘:{‘password‘:‘123456‘}, 4 ‘list3‘:{‘password‘:‘123456‘}, 5 } 6 f = open(‘black_user‘,‘r‘) 7 lock_file = f.readlines() 8 f.close() 9 count=010 count1=011 while True:12 name_input=input("please input name:")13 if count == 3:14 print("使用者名稱輸入次數到達限制")15 break16 if not name_input in div:17 print("使用者名稱錯誤")18 count +=119 if name_input in lock_file:20 print("戶名鎖定,暫停使用!")21 exit()22 23 if name_input in div:24 count -=225 password_input=str(input("please input password:"))26 if password_input == div[name_input][‘password‘]:27 print ("密碼成功")28 break29 else:30 print("密碼錯誤")31 count1 +=132 if count1 == 2:33 print("您輸入的密碼錯誤次數已達3次,將鎖定您的賬戶!")34 f = open(‘black_user‘, ‘w‘)35 f.write(‘%s‘%name_input)36 f.close()37 break
python 多使用者登入