python 多使用者登入

來源:互聯網
上載者:User

標籤: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 多使用者登入

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.