Week2-作业: 三级菜单
#!/usr/bin/en python # Author:lijun henan = { '郑州':{ "金水":{ "国贸":["360","博物馆"], "新通桥":["立交","市政府"] }, "管城":{ "商城":["华亿大厦","商城遗址"], "七里河":{"阳光城","华钻"}, "航海路":{"中原福塔","地铁5号线"}, }, "经开":{}, }, '周口':{ "麚邑":{}, "淮阳":{}, "西华":{} }, '南阳':{ "方城":{}, "舞阳":{}, "社旗":{}, }, } exit_log = False while not exit_log: for i in henan: print(i) select1 = input("请输入选择1:") if select1 in henan: while not exit_log: for j in henan[select1]: print(j) select2 = input("请输入选择2:") if select2 in henan[select1]: while not exit_log: for k in henan[select1][select2]: print(k) select3 = input("请输入选择3:") if select3 in henan[select1][select2]: while not exit_log: for m in henan[select1][select2][select3]: print(m) select4 = input("到底了,按q退出,按b返回:") if select4 == "q": exit_log = True elif select4 == "b": break elif select3 == "q": exit_log = True elif select3 == "b": break elif select2 == "q": exit_log = True elif select2 == "b": break elif select1 == "q": exit_log = True elif select1 == "b": print("--已经是最顶层,无法返回")