import datetimestr=‘*登陆程序*‘print(str.center(70,‘*‘))f=open(‘账户密码.txt‘,encoding=‘utf-8‘)a=f.read()f.close()reg=a.split(‘\n‘)users={}for i in reg: username,password=i.split(‘,‘) users[username]=passwordprint(users)f=open(‘账户密码.txt‘,encoding=‘utf-8‘)a=f.read()login_reg=a.split(‘\n‘)users={}f.close()for i in login_reg: username,password=i.split(‘,‘) users[username]=passwordtoday=datetime.datetime.today()for i in range(3): username = (input("请输入用户名:").strip()).lower() password = (input("请输入登录密码:").strip()).lower() if username==‘‘ and password==‘‘: print(‘用户名和密码不能为空!‘) elif username.lower() in users: if password.lower()==users.get(username): print(‘登陆成功,今天的日期是%s‘%today) break else:print(‘密码输入错误!‘) else:print(‘用户名不存在!‘)else:print(‘输错用户名和密码三次,不能继续‘)
原文地址:https://www.cnblogs.com/wanglun1101/p/11629072.html
时间: 2024-10-18 09:45:09