Python/Basic/chick_python_exam/Unit1_basic/program/loginAuthentication.py
2024-06-27 15:41:10 +08:00

19 lines
585 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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--- 登入失敗,拒絕服務 ---")