标签:广州市 python int 深圳 长沙 珠海 实现 韶山 highlight
利用字典实现多级菜单:
area = { ‘广西‘:{ ‘梧州‘:{ ‘岑溪‘:[‘豆腐酿‘,‘新圩米粉‘,‘茄子酿‘,‘白切鸡‘], ‘容县‘:[‘1‘,‘2‘,‘3‘], ‘苍梧‘:[‘4‘,‘5‘,‘6‘] }, ‘南宁‘:{ ‘武鸣区‘:[‘大明山‘,‘伊岭岩‘,‘灵水‘,‘明秀园‘], ‘宾阳县‘:[‘鱼生‘,‘宾阳酸辣粉‘] } }, ‘广东‘:{ ‘广州市‘:[‘越秀区‘,‘荔湾区‘,‘‘], ‘深圳市‘:[‘福田区‘,‘罗湖区‘,‘宝安区‘], ‘珠海市‘:[‘香洲区‘,‘斗门区‘,‘金湾区‘] }, ‘湖南‘:{ ‘长沙市‘:[‘长沙县‘,‘宁乡县‘,‘雨花区‘], ‘湘潭市‘:[‘雨湖区‘,‘湘潭县‘,‘韶山市‘], ‘娄底市‘:[‘娄星区‘,‘新化县‘,‘双峰县‘] } } while True: for i in area: print(i) choice = input(‘\n请输入地方名:‘) if choice in area: while True: for i2 in area[choice]: print(‘\t‘,i2) choice2 = input(‘\n请输入地方名:‘) if choice2 in area[choice]: while True: for i3 in area[choice][choice2]: print(‘\t\t‘,i3) choice3 = input(‘\n请输入地方名:‘) if choice3 in area[choice][choice2]: for i4 in area[choice][choice2][choice3]: print(‘\t\t\t‘,i4) choice4 = input(‘\n没有啦,按回车返回上一级:‘) if choice4 == ‘b‘: pass elif choice4 == ‘q‘: exit() if choice3 == ‘b‘: break elif choice3 == ‘q‘: exit() if choice2 == ‘b‘: break elif choice2 == ‘q‘: exit() if choice == ‘q‘: exit()
标签:广州市 python int 深圳 长沙 珠海 实现 韶山 highlight
原文地址:http://www.cnblogs.com/relax1949/p/7489908.html