您的位置:首页 > 其它

练习-三级菜单

2016-04-20 00:24 197 查看
#作业二:编写三级菜单
#功能:大公司通讯录,依次选择地名-->部门名-->姓名,找到需要查找人的手机号码
#author:刘志睦
#update:2016-4-11
#description:本程序,首先列出3个城市名,1,2,3
# 用户可以根据需要选择相应城市,直接输入序号即可
#输入字母b返回上级
#然后列出该城市中的部门名,1,2,3
#用户根据需要选择相应部门,直接输入序号即可
#输入字母b返回上级
#最后列出该部门的所有人员,1,2,3,。。。
#用户根据需要选择相应的人员,直接输入序号即可
#结果列出指定人员的基本信息,包括手机号
#输入字母b返回上级
#Bug:字典person只能记录一个用户的信息,返回上级没使用函数(还没学),返回只能返回一次,输入其他数字还没处理
person1 ={"Place":"Beijing","Department":"Maket","Name":"B_zhao1","Phone":"11111118"}   #北京市场部B_zhao1的详细信息
person2 ={"Place":"Shanghai","Department":"Maket","Name":"S_zhao1","Phone":"11111113"}  #上海市场部S_zhao1的详细信息
person3 ={"Place":"Guangzhou","Department":"Maket","Name":"G_zhao1","Phone":"11111119"} #广州市场部G_zhao1的详细信息
place_list = ["1.Beijing","2.Shanghai","3.Guangzhou"]    #地区名列表
department_list = ["1.Market","2.Technology","3.Finance"]   #部门列表
name_list_beijing_market = ["1.B_zhao1","2.B_qian1","3.B_sun1"]   #北京市场部人员名单
name_list_beijing_technology = ["1.B_zhao2","2.B_qian2","3.B_sun2"]  #北京技术部人员名单
name_list_beijing_finance = ["1.B_zhao3","2.B_qian3","3.B_sun3"]    #北京财务部人员名单
name_list_shanghai_market = ["1.S_zhao1","2.S_qian1","3.S_sun1"]    #上海市场部人员名单
name_list_shanghai_technology = ["1.S_zhao2","2.S_qian2","3.S_sun2"]  #上海技术部人员名单
name_list_shanghai_finance = ["1.S_zhao3","2.S_qian3","3.S_sun3"]    #上海财务部人员名单
name_list_guangzhou_market = ["1.G_zhao1","2.G_qian1","3.G_sun1"]    #广州市场部人员名单
name_list_guangzhou_technology = ["1.G_zhao2","2.G_qian2","3.G_sun2"]  #广州技术部人员名单
name_list_guangzhou_finance = ["1.G_zhao3","2.G_qian3","3.G_sun3"]     #广州财务部人员名单

print(place_list)
city_num = int(input("Please input your choice-city(1-3):"))   #选择地名,输入数字1-3
if (city_num == 1):    #如果选择1,展开北京的各部门
print(department_list)
back_first = input("Please input b to go back(b):")  # 如果按b则返回上一级目录,即展开各城市
if (back_first == "b"):
print(place_list)
city_num = int(input("Please input your choice-city(1-3):"))  # 选择地名,输入数字1-3
if (city_num == 1):  # 如果选择1,展开北京的各部门
print(department_list)

department_num = int(input("Please input your choice-department(1-3):"))
if(department_num == 1):   #如果选择1,展开北京市场部人员名单
print(name_list_beijing_market)
back_second = input("Please input b to go back(b):")     #如果按b则返回上一级目录,即展开各部门
if(back_second == "b"):
print(department_list)
department_num = int(input("Please input your choice-department(1-3):"))
if (department_num == 1):  # 如果选择1,展开北京市场部人员名单
print(name_list_beijing_market)

person_phone = int(input("Please input your choice-person(1-3):"))
if(person_phone == 1):      #选择需要查询人员的编号,即可查询相应的手机号码
print(person1)
back_third = input("Please input b to go back(b): ")    #如果按b则返回上一级目录,即展开相应的部门人员名单
if(back_third == "b"):
print(name_list_beijing_market)
person_phone = int(input("Please input your choice-person(1-3):"))
if (person_phone == 1):  # 选择需要查询人员的编号,即可查询相应的手机号码
print(person1)

elif(department_num == 2): #如果选择2,展开北京技术部人员名单
print(name_list_beijing_technology)
elif(department_num == 3): #如果选择3,展开北京财务部人员名单
print(name_list_beijing_finance)

elif (city_num == 2): #如果选择2,展开上海的各部门
print(department_list)
back_first = input("Please input b to go back(b):")  # 如果按b则返回上一级目录,即展开各城市
if (back_first == "b"):
print(place_list)
city_num = int(input("Please input your choice-city(1-3):"))  # 选择地名,输入数字1-3
if (city_num == 1):  # 如果选择1,展开北京的各部门
print(department_list)

department_num = int(input("Please input your choice-department(1-3):"))
if (department_num == 1):  # 如果选择1,展开上海市场部人员名单
print(name_list_shanghai_market)
back_second = input("Please input b to go back(b):")  # 如果按b则返回上一级目录,即展开上海各部门
if (back_second == "b"):
print(department_list)
department_num = int(input("Please input your choice-department(1-3):"))
if (department_num == 1):  # 如果选择1,展开上海市场部人员名单
print(name_list_shanghai_market)

person_phone = int(input("Please input your choice-person(1-3):"))
if (person_phone == 1):  # 选择需要查询人员的编号,即可查询相应的手机号码
print(person2)
back_third = input("Please input b to go back(b): ")  # 如果按b则返回上一级目录,即展开相应的部门人员名单
if (back_third == "b"):
print(name_list_shanghai_market)
person_phone = int(input("Please input your choice-person(1-3):"))
if (person_phone == 1):  # 选择需要查询人员的编号,即可查询相应的手机号码
print(person2)

elif (department_num == 2):  # 如果选择2,展开上海技术部人员名单
print(name_list_shanghai_technology)
elif (department_num == 3):  # 如果选择3,展开上海财务部人员名单
print(name_list_shanghai_finance)

elif (city_num == 3): #如果选择3,展开广州的各部门
print(department_list)
back_first = input("Please input b to go back(b):")  # 如果按b则返回上一级目录,即展开各城市
if (back_first == "b"):
print(place_list)
city_num = int(input("Please input your choice-city(1-3):"))  # 选择地名,输入数字1-3
if (city_num == 1):  # 如果选择1,展开北京的各部门
print(department_list)

department_num = int(input("Please input your choice-department(1-3):"))
if (department_num == 1):  # 如果选择1,展开广州市场部人员名单
print(name_list_guangzhou_market)
back_second = input("Please input b to go back(b):")  # 如果按b则返回上一级目录,即展开广州各部门
if (back_second == "b"):
print(department_list)
department_num = int(input("Please input your choice-department(1-3):"))
if (department_num == 1):  # 如果选择1,展开上海市场部人员名单
print(name_list_guangzhou_market)

person_phone = int(input("Please input your choice-person(1-3):"))
if (person_phone == 1):  # 选择需要查询人员的编号,即可查询相应的手机号码
print(person3)
back_third = input("Please input b to go back(b): ")  # 如果按b则返回上一级目录,即展开相应的部门人员名单
if (back_third == "b"):
print(name_list_guangzhou_market)
person_phone = int(input("Please input your choice-person(1-3):"))
if (person_phone == 1):  # 选择需要查询人员的编号,即可查询相应的手机号码
print(person3)

elif (department_num == 2):  # 如果选择2,展开广州技术部人员名单
print(name_list_guangzhou_technology)
elif (department_num == 3):  # 如果选择3,展开广州财务部人员名单
print(name_list_guangzhou_finance)

else:
print("Please input the correct number")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: