【发布时间】:2017-10-31 01:15:55
【问题描述】:
我正在尝试以特定格式输出员工信息。
dep_tup 是一个包含用户输入的所有不同部门名称的元组(无重复)。
dep_dict 是一个以部门为键的字典,而包含员工字典的列表作为与该键关联的值。
#Function that outputs the employees by department
def deps():
for department in dep_tup:
i = 0
total = len(dep_dict[department])
for i in range(len(dep_dict[department])):
return "%s with %d employees\n" % (dep_dict[department], total)
return "\n%s: %s, %s, $%f per year\n" % (dep_dict[department][i]["name"], dep_dict[department][i]["position"], dep_dict[department][i]["em_department"], dep_dict[department][i]["salary"])
i += 1
例如,如果用户输入销售部门的 1 名员工和运营部门的 1 名员工,则应输出如下内容:
#Sales with 1 employees
#John Doe: sales lead, sales, $50000.00 per year
#Operations with 1 employees
#Jane Doe: technician, operations, $60000.00 per year
【问题讨论】:
-
你不能连续返回语句...
标签: python python-3.x file dictionary