关于小甲鱼一段代码的疑问
def showmenu():prompt = '''
|--- 新建用户:N/n ---|
|--- 登录账号:E/e ---|
|--- 推出程序:Q/q ---|
|--- 请输入指令代码:'''
while True:
chosen = False
while not chosen:
choice = input(prompt)
if choice not in 'NnEeQq':
print('您输入的指令代码错误,请重新输入:')
else:
chosen = True
节选的一段代码,上面这段为什么要设计成这样?如果改成下面的样子会不一样吗?
while 1:
while 2:
choice = input(prompt)
if choice not in 'NnEeQq':
print('您输入的指令代码错误,请重新输入:')
else:
break
逻辑无区别
页:
[1]