使用者登入驗證
要求:
1.使用者登入輸入賬号、密碼、4位随機大寫字母驗證碼
2.驗證碼錯誤重新輸入
3.有三次機會輸入賬号密碼
count = 1
while count <= 3 :
from random import randint
num = 0
verify_code = "" # 建立一個空字元串放驗證碼
while num < 4:
verify_code += chr(randint(65, 90))
num += 1
usernum = input("請輸入賬号")
code = input("請輸入密碼")
verify_code_1 = input("請輸入驗證碼(%s)" %verify_code)
if usernum == "左志博" and code == "123" :
if verify_code_1 == verify_code:
print("輸入正确")
break
else :
print("驗證碼錯誤,請重新輸入")
continue
else :
print("輸入錯誤,你還有%s次機會" % (3-count))
count += 1
轉載于:https://www.cnblogs.com/Dani/p/9973984.html