python列表函数小例子

#
emp_list = []
while True:
    info = input("请输入员工信息:")
    if info == "":
         print("程序结束")#输入回车时结束
         break
    info_list = info.split(",")
    print(len(info_list))
    if len(info_list) != 3:
        print("格式不正确,只能输入三段")
        continue
    emp_list.append(info_list)
    print(emp_list)
    for emp in emp_list:
        print("姓名: {n},年龄:{a},工资:{s}".format(n=emp[0],a=emp[1],s=emp[2]))``

相关推荐