三国人物查询
作者:互联网
dic = { '魏国':{ '主公':{'曹操': ['孟德'], '曹丕': ['子桓'], '曹睿': ['元仲']}, '谋士':{'司马懿':['仲达'], '郭嘉':['奉孝'], '贾诩': ['文和']}, '武将': {'许褚': ['仲康'], '张辽':['文远'], '徐晃': ['公明']} }, '蜀国':{ '主公':{'刘备':['玄德 '],'刘禅:':['公嗣'],}, '谋士':{'诸葛亮':['孔明'],'庞统':['士元'],'徐庶':['元直']}, '武将':{'关羽':['云长'],'张飞':['翼德'],'赵云':['子龙']} }, '吴国': { '主公': {'孙权': ['仲谋 '], '孙策:': ['伯符'], '孙坚:': ['文台']}, '谋士': {'陆逊': ['伯言'], '周瑜:': ['公瑾'], '鲁肃': ['子敬']}, '武将': {'吕蒙': ['子明'], '甘宁:': ['兴霸'], '太史慈': ['子义']} } } while True: select = input("请输入想要查询的国家") if select == '魏国' or select == '蜀国'or select == '吴国': while True: print([k for k in dic[select]]) select_2 = input("请输入想要查询的职位'q'返回上一层") if select_2 in dic[select]: print([k for k in dic[select][select_2]]) select_3 = input("请输入想要查询的职位'q'返回上一层") if select_3 in dic[select][select_2]: print([k for k in dic[select][select_2][select_3]]) elif select_2 == 'q': break else: print('输入错误') else: print('您查找的国家不存在') continue
标签:三国,人物,dic,输入,print,input,查询,select 来源: https://www.cnblogs.com/libragyf/p/12179089.html