d_city = {
"河南" : {"郑州" : ["二七区","中原区","回族管城区","惠济区","金水区","上街区"],
"信阳" : ["浉河区","平桥区","羊山新区","南湾区","上天梯区","鸡公山区"]},
"广东":{"广州":["越秀","海珠","荔湾","天河","白云","黄埔","南沙"],
"深圳":["罗湖区","龙岗区","福田区","南山区","盐田区","宝安区","大鹏新区"]}
d_city = {
"河南" : {"郑州" : ["二七区","中原区","回族管城区","惠济区","金水区","上街区"],
"信阳" : ["浉河区","平桥区","羊山新区","南湾区","上天梯区","鸡公山区"]},
"广东":{"广州":["越秀","海珠","荔湾","天河","白云","黄埔","南沙"],
"深圳":["罗湖区","龙岗区","福田区","南山区","盐田区","宝安区","大鹏新区"]}
}
while True:#保证 break 到这一级可以循环下去
for index, key in enumerate(d_city.keys()):
print(index, key)
print('******************\n')
value_f = input("请选择区域(退出请按q,返回请按b):").strip() #first 选择,选择第一个区域
if value_f.isdigit():
value_f = int(value_f)#保证输入为数字
list_a = list(d_city.keys())[value_f]
while True:#选择正确的区域编号后,进入下一级循环
for index, key in enumerate(d_city[list_a]):#遍历序列中的元素以及它们的下标
print(index, key)#显示遍历结果
value_s = input("请选择地区(退出请按q,返回请按b):").strip()
if value_s.isdigit():
value_s = int(value_s)
list_b = list(d_city[list_a].keys())[value_s]
while True:
for index, key in enumerate(d_city[list_a][list_b]):
print(key)
value_d = input("退出请按q,返回请按b:").strip()
if value_d == 'q':
exit()
elif value_d == 'b':
break
else:print("请输入指定值")
elif value_s == 'q':
exit()
elif value_s == 'b':
break
elif value_f == 'q':
exit()
elif value_f == 'b':
break
#最后几行保证每一级都可以返回上一级,以及结束循环