2020 7.15
程序员文章站
2023-09-17 23:37:50
import timenumber = 0data_txt = open(r"C:\Users\S\Desktop\userdata.txt", mode="rt", encoding="utf-8")datas = data_txt.read()userdata_list = datas.split("\n")# print(datas)print(userdata_list)user_data = {}for i in userdata_list: j = i.split(":"...
import time
number = 0
user_data = {}
with open(r"C:\Users\S\Desktop\userdata.txt", mode="rt", encoding="utf-8") as f:
for line in f:
i, j = line.strip('\n').split(":")
user_data[i] = j
id_word = input("请输入你的账号:")
while True:
password = input("请输入你的密码:")
# 用户未注册
if id_word not in user_data.keys():
print("请输入正确的账号!")
id_word = input("请输入你的账号:")
# 判断账户与密码是否匹配
else:
if password == user_data[id_word]:
print("登陆成功!")
break
else:
print("密码输入错误,请再试一次!")
number += 1
print("您还有%d机会" % (3-number))
if number == 3:
number -= 3 #重置次数
print("次数已用尽,请五分钟后重试。")
time.sleep(300)
id_word = input("请重新输入你的账号:")
本文地址:https://blog.csdn.net/A1L__/article/details/107366855