三級菜單:此處不足 沒有考慮是否在data裏面# -*- coding:utf-8 -*-# Author :dengdata = { '北京':{ "昌平":{ "沙河":["oldboy","test"], "天通苑":["鏈家地產","我愛我家"] }, "朝陽":{ "望京":["奔馳","陌陌"], "國貿":{"CICC","HP"}, "東直門":{"Advent","飛信"}, }, "海淀":{}, }, '山東':{ "德州":{}, "青島":{}, "濟南":{} }}exit_flag = Falsewhile not exit_flag: for i in data: print(i) choice = input('請選擇進入》》1:') if choice in data: while not exit_flag: for i2 in data[choice]: print('\t',i2) choice2 = input('請選擇進入》》2:') if choice2 in data[choice]: while not exit_flag: for i3 in data[choice][choice2]: print('\t\t',i3) choice3 = input('請選擇進入》》3:') if choice3 in data[choice][choice2]: for i4 in data[choice][choice2][choice3]: print('\t\t\t',i4) choice4 =input('最後一層,輸入b返回,退出選擇q:') if choice4 == 'b': break elif choice4 == 'q': exit_flag = True if choice3 == 'b': break elif choice3 == 'q': exit_flag = True if choice2 == 'b': break elif choice2 == 'q': exit_flag = True