python 文件读取三级菜单操作

pram = open("/Users/macbook/dictionray.json","r").read()

pramdic = eval(pram)

flag = True

while flag:

for i in  pramdic:

print(i)

chose_one = input("请输入1:")

if chose_one in pramdic:

while flag:

for i1 in pramdic[chose_one]:

print(i1)

chose_two = input("请输入2:")

if chose_two in pramdic[chose_one]:

while flag:

for i2 in pramdic[chose_one][chose_two]:

print(i2)

chose_three = input("请输入3:")

if chose_three in pramdic[chose_one][chose_two]:

print(pramdic[chose_one][chose_two][chose_three])

elif chose_three == "q":

flag = False

chose_four = input("请输入4:")

if chose_four == "q":

flag = False

else:

print("输入有误~")

elif chose_two == "q":

flag = False

else:

print("输入有误~")

elif chose_one == "q":

flag = False

else:

print("输入有误~")

你可能感兴趣的:(python 文件读取三级菜单操作)