python 循环的概念



china ={
"江苏":
{"南京":
{"玄武区":
{"中山东路":
{"1路","3路","5路","9路","25路","34路","801路","805路","824路"},
"天路":{},
"后路":{}
},"秦淮区":{},"鼓楼区":{},"建邺区":{}
},
"苏州":{},
"常州":{}
}
,"四川":{
"成都市":{"test":"123"},
"绵阳市":{"区":"小泉真"}
}
}

# print(china["江苏"]["南京"]["玄武区"])
exit_flag = False
while not exit_flag :
for i in china:
print(i)
choice = input("选择进入>>>>:")
if choice in china:
print(choice)
while not exit_flag:
for i2 in china[choice]:
print(' ',i2)
choice2 = input("选择进入2>>>>:")
if choice2 in china[choice]:
while not exit_flag:
for i3 in china[choice][choice2]:
print(' ', i3)
choice3 = input("选择进入3>>>>:")
if choice3 in china[choice][choice2]:
while not exit_flag:
for i4 in china[choice][choice2][choice3]:
print(' ',i4)
choice4 = input("选择进入4>>>>:")
if choice4 in china[choice][choice2][choice3]:
while not exit_flag:
for i5 in china[choice][choice2][choice3][choice4]:
print(' ',i5)
choice5 = input("最后一层,按b返回>>>>:")
if choice5 == 'b':
break
elif choice5 == 'q':
exit_flag =True
elif choice4 == 'b':
break
elif choice4 == 'q':
exit_flag = True
elif choice3 == 'b':
break
elif choice3 == 'q':
exit_flag = True
elif choice2 == 'b':
break
elif choice2 == 'q':
exit_flag = True
elif choice == 'b':
break
elif choice == 'q':
exit_flag = True
















原文地址:https://www.cnblogs.com/anhao-world/p/12776011.html