python3.0 類比使用者登入,三次錯誤鎖定

來源:互聯網
上載者:User

標籤:python3.0   鎖定   使用者登入   

# -*- coding:utf-8 -*-#需求類比使用者登入,超過三次錯誤鎖定不允許登陸count = 0#realname passwdReal_Username = "test"Real_Password = "test"#讀取黑名單的內容f = open(‘black_user‘,‘r‘)lock_file = f.read()f.close()Username = input(‘請輸入使用者名稱:‘)#判斷輸入使用者是否在黑名單內,如果在則不允許輸入密碼for i in range(1):    if lock_file == Username:        print(‘對不起,您的使用者鎖定,暫時不允許使用!‘)        exit()    else:        continue#嘗試輸入密碼並對輸入次數進行計數for i in range(3):    Password = input("請輸入密碼:")    if Username == Real_Username and Password == Real_Password:        print("登入成功")        break    else:        print("登入失敗")    count += 1#如果輸入三次錯誤密碼,則提示使用者名稱鎖定,並將使用者名稱拉黑if count == 3:    print("對不起,您輸入的密碼錯誤次數已經達到3次,您的使用者名稱將被鎖定")    f = open("black_user","w")    f.write("%s"%Username)    f.close()


本文出自 “Dr小白” 部落格,請務必保留此出處http://metis.blog.51cto.com/1203503/1963377

python3.0 類比使用者登入,三次錯誤鎖定

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.