def main():
while True:
menum() #while Ture 相当于一只执行无线循环语句,这里显示系统主菜单,直到break退出系统
choice = input('请选择')
if type(eval(choice)) == int:
print(type(eval(choice)))
print(choice)
if choice in [0,1,2,3,4,5,6]:
if choice == 0:
answer = input('你确定要退出系统么y/n')
if answer =='y'or answer=='Y':
break
else:
continue
else:
print('jjjjjj')
def menum():
print('----------学生管理系统----------')
原因在于这里的变量choice是字符型。
if choice in [0,1,2,3,4,5,6]:
if choice == 0:
answer = input('你确定要退出系统么y/n')
......
可以在输入choice变量之后,统一处理一下变量choice。例如,choice=eval(choice)
def main():
while True:
menum() # while Ture 相当于一只执行无线循环语句,这里显示系统主菜单,直到break退出系统
choice = input('请选择')
if choice.isdigit():
choice = int(choice)
print(choice, type(choice))
if 0 <= choice <= 6:
if choice == 0:
answer = input('你确定要退出系统么y/n')
if answer == 'y' or answer == 'Y':
break
else:
continue
else:
print('没有该选项')
else:
print('输入的不是数字!')
def menum():
print('----------学生管理系统----------')
if __name__ == '__main__':
main()
您好,我是问答小助手,你的问题已经有小伙伴为您解答了问题,您看下是否解决了您的问题,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632