1. 程式人生 > >python-簡單登入指令碼

python-簡單登入指令碼


import datetime
today = datetime.date.today()
username = 'aaa'
password = '123'
count = 0
while count <3:
    uname = input('請輸入使用者名稱:')
    pwd = input('請輸入密碼:')
    if not uname.strip() or not pwd.strip():
        # print(uname)
        # print(pwd)
        print('使用者名稱或密碼不能為空')
    elif uname != 'aaa'or pwd != '123' :
        # print(type(uname))
        print('使用者名稱或密碼錯誤,請重新輸入')
    else :
        welcome = '恭喜你登入成功了,歡迎%s 今天是%s '%(uname,today)
        print(welcome)
        break
    count+=1
else:
    print('錯誤次數超過3次,不允許登入')