作业
count = 0
while count < 3:
user_name = input("请输入你的用户名:").strip()
user_pwd = input("请输入你的密码:").strip()
with open('a.txt', mode='rt', encoding='utf-8')as f:
# 打开a.txt文件
for line in f:
# 读入到内存
name, pwd = line.strip().split(":")
# 解压赋值
if user_name == name and user_pwd == pwd:
# 用户输入比对文件
print('登录成功')
count = 4
break
else:
print("账号密码错误,请重新输入.")
count += 1

浙公网安备 33010602011771号