print("功能菜单".center(30,'-'))
print("注册请输入0,登录请输入1")
flag = input(">")
if flag == "0":
print("注册".center(30,'-'))
user = input("请输入用户名:").strip()
password = input("请输入密码:").strip()
with open('db.txt','a',encoding='utf-8') as f:
info = "%s:%s\n"%(user, password)
f.write(info)
print("注册成功!")
elif flag =="1":
print("登录".center(30, '-'))
user = input("请输入用户名:").strip()
password = input("请输入密码:").strip()
with open('db.txt', 'r', encoding='utf-8') as f:
for i in f:
name, pwd = i.strip("\n").split(":")
if user == name and password == pwd:
print("登录成功!")
break
else:
print("登录失败!")
else:
print("请输入正确的指令")