user = ['xuan','chen']
passed = ['159','564']
s1 = '''
'1).注册新用户'
'2).用户登录'
'3).注销用户'
'4).显示用户名'
'5).修改用户信息'
'6).退出系统(exit(0))'
'''
while 1:
print(s1)
choose = int(input('请输入选项:'))
if choose == 1:
# print('注册新用户')
newname = input('用户名')
if newname in user:
print('用户名已存在')
else:
user.append(newname)
newpass = input('请输入新密码:')
passed.append(newpass)
print(f'添加新用户{newname}成功')
elif choose == 2:
# print('用户登录')
newnname = input('请输入用户名:')
newnpass = input('请输入密码:')
if newnname in user and passed :
print('登陆成功')
else:
print('登陆失败')
elif choose == 3:
# print('注销用户')
newnname = input('请输入你需要删除的用户')
if newnname in user:
indexnewnname = user.index(newnname)
user.remove(newnname)
passed.pop(indexnewnname)
print(f'注销用户成功')
else:
print('此用户不存在')
elif choose == 4:
# print('显示用户信息')
for i in range(len(user)):
print(user[i],passed[i],sep=' -- ')
elif choose == 5:
# print('修改')
new = input('请输入你需要修改的用户:')
if new in user :
indexnew = user.index(new)
user[indexnew] = input('请输入你需要修改的用户名:')
passed[indexnew] = input('请输入你需要修改的用户密码:')
print('修改成功')
else:
print('此用户不存在')
break
elif choose == 6:
print('退出系统(exit(0))')
break
else:
print('输入有误,请输入1--6的整数值')