USIGN PYTHON:提供公司管理字典,生成一个函数,使用递归以获取打印输出如下
Python
Company = {“ name”:“ George”,“ Manages”:[{“ name”:“ James”,“ Manages”:[{“ name”:“ Jill”},{“ name”:“ Jenny”} ]},{“ name”:“ jamila”,“ manages”:[{“ name”:“ jewel”},{“ name”:“ jasmine”},{“ name”:“ jeremey”}]}}}}
乔治经营一家公司。他管理詹姆斯和贾米拉,他们每个人都有一个小团队要管理。詹姆斯的团队是吉尔和珍妮。在贾米拉(Jamila)的团队中,有珠宝,茉莉和杰里米。
结果应该是:
乔治在1级 詹姆斯在2级 吉尔处于3级 珍妮处于3级 贾米拉(Jamila)处于2级 珠宝处于3级 茉莉在3级 耶利米(Jeremey)处于3级
Python
company = {"name":"George", "manages":[{"name":"James", "manages":[{"name":"Jill"},{"name":"Jenny"}]}, {"name":"Jamila", "manages":[{"name":"Jewel"}, {"name":"Jasmine"}, {"name":"Jeremey"}]}]}
George runs a company. He manages James and Jamila, who each have a small team to manage. In James' team are Jill and Jenny. In Jamila's team are Jewel, Jasmine and Jeremy.
Result should be:
George is at level 1
James is at level 2
Jill is at level 3
Jenny is at level 3
Jamila is at level 2
Jewel is at level 3
Jasmine is at level 3
Jeremey is at level 3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于Python,答案几乎相同
For python the answer is nearly identical