简陋三级交互
Posted 风水涣
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简陋三级交互相关的知识,希望对你有一定的参考价值。
#conding:utf-8 # 选做题:用户交互,显示省市县三级联动的选择 # dic = { "河北": { "石家庄": ["鹿泉", "藁城", "元氏"], "邯郸": ["永年", "涉县", "磁县"], }, "河南": { "信阳": ["光山", "固始", "新县"], "南阳": ["内乡", "社旗", "镇平"], }, "山西": { "运城": ["万泉", "荣河", "临晋", "猗氏"], "太原": ["清徐", "阳曲", "娄烦"], }, } print("默认不输入自动退出上一层") tag = True while tag: print( ‘\n‘"请选择省份:") for i in dic: print(i,end=‘ ‘) a = input(‘\n‘"开始你的表演:") if a in dic.keys(): while tag: for j in dic[a]: print(j,end=‘ ‘) b = input(‘\n‘"请选择市:") if b in dic[a].keys(): while tag: for k in dic[a][b]: print(k,end=‘ ‘) c = input(‘\n‘"请选择县:") if c in dic[a][b]: print("已经选择:",c) tag = False elif len(c) == 0: break elif c not in dic[a][b]: print("找不到这个县") elif len(b) == 0: break elif b not in dic[a].keys(): print("找不到这个市") elif len(a) == 0: tag = False elif a not in dic.keys(): print("找不到这个省份")
以上是关于简陋三级交互的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 xcode 将快照划分为多个片段,以便让用户与每个片段进行交互?