简单的三级菜单

 1 #!/usr/bin/env python
 2 #-*- coding:utf-8 -*-
 3 #3.0python版本以上运行
 4 
 5 city = {
 6     'sicuan':{'chengdu':{'wuhouqu':['xxx','111']}},
 7     'guangdong':{'guangzhou':{'huaduqu':['yyy','222']}}
 8 }
 9 
10 while True:
11     for i in city:
12         print(i)
13     choice = input("choice_begin>>>")
14     if choice in city:
15         for i2 in city[choice]:
16             print(i2)
17         choice2 = input("chice2>>>")
18         if choice2 in city[choice]:
19             for i3 in city[choice][choice2]:
20                 print(i3)
21             choice3 = input("chice3>>>")
22             if choice3 in city[choice][choice2]:
23                 for i4 in city[choice][choice2][choice3]:
24                     print(i4)
25                 choice4= input("输入Q退出或者回车继续>>>")
26                 if choice4 == 'Q' or choice4 == 'q':
27                     exit()
原文地址:https://www.cnblogs.com/jesse-gong/p/7655030.html