请构建一个院系专业字典,并根据描述完成相关操作:
构建一个院系专业字典,格式如下{‘院名’:{‘系名’:[专业名称]}}
实现院系专业分级查找功能
实现院系专业添加功能
college_dept_dict = {'信息学院':{'计算机科学系':['软件开发','计算机应用']},
'管理学院':{'工业管理系':['工业工程','智能制造'],'社会工作系':['社会工作']}
}
def show():
for k,v in college_dept_dict.items():
print(k)
for ik,iv in v.items():
print("\t", ik,iv)
def add(c,d,p):
if c in college_dept_dict:
d1 = college_dept_dict[c]
if d in d1:
temp = d1[d]
temp.append(p)
d1[d] = temp
def check(p):
for k,v in college_dept_dict.items():
for ik,iv in v.items():
if p in iv:
return "{}-{}-{}".format(k,ik,p)
return "没有找到{}".format(p)
show()
add('信息学院','计算机科学系','大数据分析')
print('----------------------------------')
show()
print(check("智能制造"))
print(check("汉语言"))