三級聯動按照等級分別查詢省市區
阿新 • • 發佈:2020-12-16
技術標籤:python
使用者互動顯示類似省市縣N級聯動的選擇
a. 允許使用者增加內容
b. 允許使用者選擇檢視某一個級別內容
sheng = []
shi = []
qu = []
dp = {"山西省": {"運城市": ["永濟縣", "臨猗縣", "河津縣"], "晉城市": ["沁水縣", "澤州縣", "陽城縣"], "呂梁市": ["文水縣", "孝義縣" , "臨汾縣"]}, "河北省": {"廊坊市": ["固安縣", "香河縣", "永清縣"], "保定市": ["高陽縣", "容城縣", "曲陽縣"], "衡水市": ["阜城縣", "武邑縣", "安平縣"]}}
for i in dp.keys():
sheng.append(i)
for j1 in dp. values():
for j2 in dict(j1).keys():
shi.append(j2)
for j1 in dp.values():
for j2 in dict(j1).values():
for j3 in j2:
qu.append(j3)
print("省"+":"+str(sheng))
print("市"+":"+str(shi))
print("區"+":"+str(qu))