Python基礎,簡單的登錄驗證

初次學習python,一頭霧水,寫了個簡單的登錄驗證,做做筆記

username = 'cc' #用戶名
userpassword = '123'    #密碼

count = 0         #計數器
while count<3:      #如果計數小於3,即0,1,2共三次,則執行以下代碼
    _username = input("USER:")  
    _userpassword = input("PW:")
    if _username == username and _userpassword == userpassword:   #判斷用戶輸入的用戶名和密碼是否一致
        print("wlcome",username,"back.~~v-v".format(username=username))
        break    #一致則跳出循環
    elif count<2: 
        print("not this user or password,try again")

    count +=1  
else:
    print("lock!!!",username.format(username=username))

代碼很簡單,希望一年後可以寫出實用點的代碼

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章