1 #作业二:编写三级菜单 2 #功能:大公司通讯录,依次选择地名-->部门名-->姓名,找到需要查找人的手机号码 3 #author:刘志睦 4 #update:2016-4-11 5 #description:本程序,首先列出3个城市名,1,2,3 6 # 用户可以根据需要选择相应城市,直接输入序号即可 7 #输入字母b返回上级 8 #然后列出该城市中的部门名,1,2,3 9 #用户根据需要选择相应部门,直接输入序号即可 10 #输入字母b返回上级 11 #最后列出该部门的所有人员,1,2,3,。。。 12 #用户根据需要选择相应的人员,直接输入序号即可 13 #结果列出指定人员的基本信息,包括手机号 14 #输入字母b返回上级 15 #Bug:字典person只能记录一个用户的信息,返回上级没使用函数(还没学),返回只能返回一次,输入其他数字还没处理 16 person1 ={"Place":"Beijing","Department":"Maket","Name":"B_zhao1","Phone":"11111118"} #北京市场部B_zhao1的详细信息 17 person2 ={"Place":"Shanghai","Department":"Maket","Name":"S_zhao1","Phone":"11111113"} #上海市场部S_zhao1的详细信息 18 person3 ={"Place":"Guangzhou","Department":"Maket","Name":"G_zhao1","Phone":"11111119"} #广州市场部G_zhao1的详细信息 19 place_list = ["1.Beijing","2.Shanghai","3.Guangzhou"] #地区名列表 20 department_list = ["1.Market","2.Technology","3.Finance"] #部门列表 21 name_list_beijing_market = ["1.B_zhao1","2.B_qian1","3.B_sun1"] #北京市场部人员名单 22 name_list_beijing_technology = ["1.B_zhao2","2.B_qian2","3.B_sun2"] #北京技术部人员名单 23 name_list_beijing_finance = ["1.B_zhao3","2.B_qian3","3.B_sun3"] #北京财务部人员名单 24 name_list_shanghai_market = ["1.S_zhao1","2.S_qian1","3.S_sun1"] #上海市场部人员名单 25 name_list_shanghai_technology = ["1.S_zhao2","2.S_qian2","3.S_sun2"] #上海技术部人员名单 26 name_list_shanghai_finance = ["1.S_zhao3","2.S_qian3","3.S_sun3"] #上海财务部人员名单 27 name_list_guangzhou_market = ["1.G_zhao1","2.G_qian1","3.G_sun1"] #广州市场部人员名单 28 name_list_guangzhou_technology = ["1.G_zhao2","2.G_qian2","3.G_sun2"] #广州技术部人员名单 29 name_list_guangzhou_finance = ["1.G_zhao3","2.G_qian3","3.G_sun3"] #广州财务部人员名单 30 31 print(place_list) 32 city_num = int(input("Please input your choice-city(1-3):")) #选择地名,输入数字1-3 33 if (city_num == 1): #如果选择1,展开北京的各部门 34 print(department_list) 35 back_first = input("Please input b to go back(b):") # 如果按b则返回上一级目录,即展开各城市 36 if (back_first == "b"): 37 print(place_list) 38 city_num = int(input("Please input your choice-city(1-3):")) # 选择地名,输入数字1-3 39 if (city_num == 1): # 如果选择1,展开北京的各部门 40 print(department_list) 41 42 department_num = int(input("Please input your choice-department(1-3):")) 43 if(department_num == 1): #如果选择1,展开北京市场部人员名单 44 print(name_list_beijing_market) 45 back_second = input("Please input b to go back(b):") #如果按b则返回上一级目录,即展开各部门 46 if(back_second == "b"): 47 print(department_list) 48 department_num = int(input("Please input your choice-department(1-3):")) 49 if (department_num == 1): # 如果选择1,展开北京市场部人员名单 50 print(name_list_beijing_market) 51 52 person_phone = int(input("Please input your choice-person(1-3):")) 53 if(person_phone == 1): #选择需要查询人员的编号,即可查询相应的手机号码 54 print(person1) 55 back_third = input("Please input b to go back(b): ") #如果按b则返回上一级目录,即展开相应的部门人员名单 56 if(back_third == "b"): 57 print(name_list_beijing_market) 58 person_phone = int(input("Please input your choice-person(1-3):")) 59 if (person_phone == 1): # 选择需要查询人员的编号,即可查询相应的手机号码 60 print(person1) 61 62 elif(department_num == 2): #如果选择2,展开北京技术部人员名单 63 print(name_list_beijing_technology) 64 elif(department_num == 3): #如果选择3,展开北京财务部人员名单 65 print(name_list_beijing_finance) 66 67 elif (city_num == 2): #如果选择2,展开上海的各部门 68 print(department_list) 69 back_first = input("Please input b to go back(b):") # 如果按b则返回上一级目录,即展开各城市 70 if (back_first == "b"): 71 print(place_list) 72 city_num = int(input("Please input your choice-city(1-3):")) # 选择地名,输入数字1-3 73 if (city_num == 1): # 如果选择1,展开北京的各部门 74 print(department_list) 75 76 department_num = int(input("Please input your choice-department(1-3):")) 77 if (department_num == 1): # 如果选择1,展开上海市场部人员名单 78 print(name_list_shanghai_market) 79 back_second = input("Please input b to go back(b):") # 如果按b则返回上一级目录,即展开上海各部门 80 if (back_second == "b"): 81 print(department_list) 82 department_num = int(input("Please input your choice-department(1-3):")) 83 if (department_num == 1): # 如果选择1,展开上海市场部人员名单 84 print(name_list_shanghai_market) 85 86 person_phone = int(input("Please input your choice-person(1-3):")) 87 if (person_phone == 1): # 选择需要查询人员的编号,即可查询相应的手机号码 88 print(person2) 89 back_third = input("Please input b to go back(b): ") # 如果按b则返回上一级目录,即展开相应的部门人员名单 90 if (back_third == "b"): 91 print(name_list_shanghai_market) 92 person_phone = int(input("Please input your choice-person(1-3):")) 93 if (person_phone == 1): # 选择需要查询人员的编号,即可查询相应的手机号码 94 print(person2) 95 96 elif (department_num == 2): # 如果选择2,展开上海技术部人员名单 97 print(name_list_shanghai_technology) 98 elif (department_num == 3): # 如果选择3,展开上海财务部人员名单 99 print(name_list_shanghai_finance) 100 101 elif (city_num == 3): #如果选择3,展开广州的各部门 102 print(department_list) 103 back_first = input("Please input b to go back(b):") # 如果按b则返回上一级目录,即展开各城市 104 if (back_first == "b"): 105 print(place_list) 106 city_num = int(input("Please input your choice-city(1-3):")) # 选择地名,输入数字1-3 107 if (city_num == 1): # 如果选择1,展开北京的各部门 108 print(department_list) 109 110 department_num = int(input("Please input your choice-department(1-3):")) 111 if (department_num == 1): # 如果选择1,展开广州市场部人员名单 112 print(name_list_guangzhou_market) 113 back_second = input("Please input b to go back(b):") # 如果按b则返回上一级目录,即展开广州各部门 114 if (back_second == "b"): 115 print(department_list) 116 department_num = int(input("Please input your choice-department(1-3):")) 117 if (department_num == 1): # 如果选择1,展开上海市场部人员名单 118 print(name_list_guangzhou_market) 119 120 person_phone = int(input("Please input your choice-person(1-3):")) 121 if (person_phone == 1): # 选择需要查询人员的编号,即可查询相应的手机号码 122 print(person3) 123 back_third = input("Please input b to go back(b): ") # 如果按b则返回上一级目录,即展开相应的部门人员名单 124 if (back_third == "b"): 125 print(name_list_guangzhou_market) 126 person_phone = int(input("Please input your choice-person(1-3):")) 127 if (person_phone == 1): # 选择需要查询人员的编号,即可查询相应的手机号码 128 print(person3) 129 130 elif (department_num == 2): # 如果选择2,展开广州技术部人员名单 131 print(name_list_guangzhou_technology) 132 elif (department_num == 3): # 如果选择3,展开广州财务部人员名单 133 print(name_list_guangzhou_finance) 134 135 else: 136 print("Please input the correct number")
时间: 2024-11-05 15:45:54