Python/Basic/chick_python_exam/Unit1_basic/program/loginAuthentication.py

19 lines
585 B
Python
Raw Permalink Normal View History

#Program: loginAuthentication.py
#Function: 由鍵盤輸入的使用者名稱與密碼是否正確若輸入錯誤超過3次則被踢出
print("***** 歡迎使用軟體系統 *****")
failed, OK = 0, False
while (failed < 3) and (not OK):
userName = input("\n登入帳號 ==> ")
password = input("輸入密碼 ==> ")
if (userName == "python") and (password == "EL308"):
OK = True
print("\n--- 登入成功,歡迎使用 ---")
else:
failed += 1
print("使用者名稱或密碼有誤,重新輸入\a")
if (failed >= 3):
print("\n--- 登入失敗,拒絕服務 ---")