# -*- coding:utf-8 -*-
#Author:Mr Gan
china_map ={
"华南区":
{
"广东省":{"广州市":["越秀区","天河区"],"东莞市":["哥台区","沧桑区"]},
"海南省":{"海口市":["龙河区","丰台区"],"三亚市":["苍山区","晋安区"]}
},
"华北区":
{
"河北省":{"石家庄市":['台州区','河内区'],"唐山市":['台南区','雄安区']}
}}
while True:
for i in china_map:#遍历第一级key
print(i)
choice_1 = input("选择进入》》:")
if choice_1 in china_map:
while True:
for i2 in china_map[choice_1]:#遍历第二级key
print("\t\t",i2)
choice_2 = input("选择进入》》:")
if choice_2 == "q":
break
if choice_2 in china_map[choice_1]:
while True:
for i3 in china_map[choice_1][choice_2]:#遍历第三级key
print("\t\t\t\t", i3)
choice_3 = input("选择进入》》:")
if choice_3 == "q":
break
if choice_3 in china_map[choice_1][choice_2]:
while True:
for i4 in china_map[choice_1][choice_2][choice_3]:
print("\t\t\t\t\t\t",i4)
choice_4 = input("最后一层,按q返回:")
if choice_4 == "q":
break
else:
pass
代码有点low