标签:style [] isp rip while spl color ide view
while循环实现三级菜单
# -*- coding: utf-8 -*- #__author__:Selid #__date__:2018/12/13 menu_all={ ‘甘肃省‘:{ ‘兰州市‘:{ ‘城关区‘:{}, ‘七里河区‘:{}, ‘安宁区‘:{}, ‘西固区‘:{}, ‘榆中县‘:{}, ‘永登县‘:{} }, ‘天水市‘:{ ‘秦州区‘:{}, ‘秦安县‘:{}, ‘甘谷县‘:{}, ‘武山县‘:{}, ‘张家川县‘:{}, }, ‘武威市‘:{ ‘古浪县‘:{}, ‘凉州区‘:{}, ‘民勤县‘:{}, ‘天祝县‘:{}, }, ‘张掖市‘:{ ‘甘州区‘:{}, ‘高台县‘:{}, ‘民乐县‘:{}, ‘临泽县‘:{}, }, }, ‘陕西省‘:{ ‘西安市‘:{ ‘新城区‘:{}, ‘莲湖区‘:{}, ‘莲湖区‘:{}, ‘未央区‘:{}, ‘雁塔区‘:{}, ‘灞桥区‘:{}, ‘阎良区‘:{}, ‘阎良区‘:{}, ‘长安区‘:{}, }, ‘宝鸡市‘:{ ‘秦都区‘:{}, ‘渭城区‘:{}, ‘长武县‘:{}, ‘淳化县‘:{}, ‘旬邑县‘:{}, }, ‘铜川市‘:{ ‘临渭区‘:{}, ‘华州区‘:{}, ‘大荔县‘:{}, ‘合阳县‘:{}, }, ‘延安市‘:{ ‘宝塔区‘:{}, ‘按赛区‘:{}, ‘延长线‘:{}, ‘延川县‘:{}, }, } } parent_layers=[] carrent_layer=menu_all while True: for key in carrent_layer: print key choice=input(‘>>>‘).strip() if len(choice)==0:continue if choice in carrent_layer: parent_layers.append(carrent_layer) carrent_layer=carrent_layer[choice] elif choice==‘b‘: if parent_layers: carrent_layer=parent_layers.pop() else:print ‘无此项‘ else: print ‘programes exited‘
标签:style [] isp rip while spl color ide view
原文地址:https://www.cnblogs.com/selid/p/10132829.html