运行环境:
python 3.7.4
程序代码:
#Author: Caesars import datetime print(datetime.datetime.now()) username = "Caesars" password = "123456" count = 0 while count < 3: name = input("please input your username:") pwd = input("please input your password:") if username == name and password == pwd: print("welcome %s login success!" %name) break else: print("your input name or password error") count += 1 if count == 3: continue print("You have entered %d times,Cumulative error input three times,Your account will be locked!" %count) if count >= 3: print("You have entered 3 times in total,Your account has been locked!")