任务内容:
1、输入用户名和密码
2、认证成功后显示欢迎信息
3、输错3次后锁定
流程图:
代码:
1、主文件
1 import sys 2 3 lock = "lock.txt" 4 logfile = "login.txt" 5 login_info = 0 6 i = 0 7 8 while i < 3 and login_info== 0 : 9 name = input("Please input your name: ") 10 11 f = open(lock, "r") 12 for line in f.readlines(): 13 # if name in line: 14 if name == line.strip(): 15 f.close() 16 sys.exit('