用户登录与注册
用户登录与注册:用函数封装功能def register(user):
if user in info:
user = input('此用户名已被使用,请重新输入:')
password = input('请输入密码:')
info = password
print('注册成功,赶紧试试登陆吧^_^')
def login():
user = input('请输入登陆名:')
if not(user in info):
user = input('登陆名不存在,请重新输入:')
password = input('请输入密码:')
if info == password:
print('欢迎进入XXOO系统,点击右上角的x结束程序')
else:
print('密码错误')
welcome = """
|---新建用户:N/n---|
|---登录账号:E/e---|
|---退出程序:Q/q---|
|---请输入指令代码:
"""
info = {}
while True:# 循环用来多次操作直到退出程序
choice = input(welcome)
if (choice == 'N') or (choice == 'n'):
user1 = input('请输入用户名:')
register(user1)
elif (choice == 'E') or (choice == 'e'):
login()
elif (choice == 'Q') or (choice == 'q'):
print('感谢使用,再见!')
break
页:
[1]