|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
contacts = dict()
while 1:
print('\n|--- 新建用户:N/n ---|')
print('|--- 登录账户:E/e ---|')
print('|--- 推出程序:Q/q ---|')
a = {'N','n','E','e','Q','q'}
instr = input('|--- 请输入指令代码:')
if instr in a:
if instr == 'N' or instr == 'n':
name = input('请输入用户名:')
while name in contacts:
print('此用户名已经被使用,', end='')
name = input('请重新输入:')
continue
else:
contacts[name] = input('请输入密码:')
print("注册成功,赶紧试试登录吧")
if instr == 'E' or instr == 'e':
name = input('请输入用户名:')
while name not in contacts:
print('您输入的用户名不存在,', end='')
name = input('请重新输入:')
continue
else:
code = input('请输入密码:')
while code != contacts[name]:
code = input('密码错误,请输入密码:')
continue
else:
print('欢迎进入系统,请点击右上角X结束程序')
break
if instr == 'Q' or instr == 'q':
break
else:
print('输入指令有误')
逻辑没有什么问题
但是所有的continue和它下面的else都可以删掉,当然要调整一下缩进
|
|