# -*- coding:utf-8 -*-#Author:Mr Ganchina_map ={ "華南區": { "廣東省":{"廣州市":["越秀區","天河區"],"東莞市":["哥台區","滄桑區"]}, "海南省":{"海口市":["龍河區","丰台區"],"三亞市":["蒼山區","晉安 ...
# -*- 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