import json
def login_interface():
while True:
print("==========================")
print(" ")
print(" *欢迎来到XX管理系统* ")
print(" ")
print(" ♦ 1.登 录 ")
print(" ♦ 2.注 册 ")
print(" ♦ 3.退 出 ")
print("==========================")
x = input("请选择(1-3):")
if int(x) == 3:
break
elif int(x) == 1:
with open("test.txt", "r", encoding="utf-8") as f:
users = eval(f.read())
user_name = input("请输入账号(3~6位):")
passwork = input("请输入密码(6~12位):")
if not 3 <= len(user_name) <= 6 and not 6 <= len(passwork) <= 12:
print("登陆失败账号密码长度不对,请重新登陆!")
elif user_name not in users:
print("此账号没被注册!请重新登陆!")
elif users[user_name] != passwork:
print("登陆失败!密码不对!请重新登陆!")
elif users[user_name] == passwork:
print("登陆成功!")
welcome_screen(user_name)
break
elif int(x) == 2:
with open("test.txt", "r", encoding="utf-8") as f:
users = eval(f.read())
user_name = input("请输入账号(3~6位):")
passwork = input("请输入密码(6~12位):")
if not 3 <= len(user_name) <= 6 and not 6 <= len(passwork) <= 12:
print("注册的账号密码长度不对!请重新注册")
else:
users[user_name] = passwork
with open("test.txt", "w", encoding="utf-8") as f:
f.write(str(users))
print("注册成功!请登录")
return "欢迎下次光临!"
def welcome_screen(user_name):
print("欢迎来到%s管理系统" % user_name)
print(" ")
print(" 🔺·1.登陆 ")
print(" 🔺·1.注册 ")
print(" 🔺·1.退出 ")
return
print(login_interface())
day12作业
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...