我正在尝试创建一个菜单。这样做的目的是让脚本在选择第二个时循环回到主菜单。它循环回来,但当我选择1号它只是继续循环。我该怎么解决这个问题。你知道吗
import os
import sys
def mainmenu():
print """
this is a test menu
"""
mainmenu()
choice = raw_input("DMF>>")
if choice == '1':
def men1():
print """
this is the second menu
"""
men1()
def back():
men1_actions['mainmenu']()
men1_actions = {
'mainmenu': mainmenu,
'2': back,
}
while True:
choice2 = raw_input("DMF>>")
if choice2 == '2':
back()
我不确定你到底是关于什么的,但是你可以先定义函数,然后只调用一个原始输入来指示输入是1还是2。你知道吗
相关问题 更多 >
编程相关推荐