import datetime #導(dǎo)入時(shí)間模塊
usearname='brtc'
passwd='123456'
times=2? ? ? #記錄用戶輸入賬號(hào)的次數(shù)
while times >=0:
? ? input_name = input('請輸入usearname:')
? ? input_passwd = input('請輸入password:')
#當(dāng)輸入的賬號(hào)和密碼正確,提示登錄和日期,然后程序結(jié)束
? ? if usearname==input_name and passwd==input_passwd:
? ? ? ? print('歡迎'+usearname+'登錄! 今天的日期是{}'.format(datetime.datetime.today()))
? ? ? ? break
#當(dāng)輸入的賬號(hào)和密碼為空時(shí),提示不能為空,并提示還有幾次剩余次數(shù)
? ? elif input_passwd=='' or input_name=='':
? ? ? ? print('賬號(hào)或密碼不能為空!')
? ? ? ? print('溫馨提示,您還有'+str(times)+'次機(jī)會(huì)!\n')
? ? else:
#當(dāng)輸入的賬號(hào)和密碼不為空時(shí)且次數(shù)不等于0提示輸入錯(cuò)誤,并提示還有幾次剩余次數(shù)
? ? ? ? if times !=0:
? ? ? ? ? ? print('\n賬號(hào)或密碼輸入錯(cuò)誤')
? ? ? ? ? ? print('溫馨提示,您還有'+str(times)+'次機(jī)會(huì)!\n')
#當(dāng)次數(shù)等于0時(shí),提示程序結(jié)束
? ? ? ? else:
? ? ? ? ? ? print('您當(dāng)前三次輸入錯(cuò)誤,程序結(jié)束!')
? ? times-=1