美文网首页
day13作业

day13作业

作者: 逆流而上_2eb6 | 来源:发表于2018-10-20 15:19 被阅读0次
    def modification_studentinfo(student,user_info):
        while 1:
            key1 = input("请输入要修改的信息(key)")
            if key1 not in student:
                print("没有该信息")
                value = input("1.重新输入\n2.返回\n请输入1-2")
                if value == "1":
                    continue
                return
            value1 = input("请输入新的值")
            student[key1] = value1
            re = file_manager.json_write(current_user + ".json", user_info)
            if re:
                print("修改成功")
            else:
                print("修改失败")
            value = input("1.再次修改\n2.返回\n请输入1-2")
            if value == "1":
                continue
            else:
                return
    
    
    def modification_student():
        user_info = get_current_userinfo()
        all_students = user_info.get(key_all_students, [])
        if not all_students:
            print("没有可以修改的学生")
            return
        while 1:
            print("1.按学号查找并修改该学生"
                  "\n2.按名字查找并修改该学生"
                  "\n3.退出")
            value = input("请输入(1-3)")
            if value == "1":
                stu_id = input("请输入id")
                student = find_student_with_id(stu_id,all_students)
                if not student:
                    print("没有该学生")
                    continue
                modification_studentinfo(student,user_info)
            if value == "2":
                stu_id = input("请输入姓名")
                students = find_student_with_name(stu_id, all_students)
                if not students:
                    print("没有该学生")
                    continue
                while 1:
                    num = input("请输入要修改的学生的编号:\n输入q退出")
                    if num == "q":
                        break
                    if num.isnumeric() and num in range(len(students)):
                        student=students[int(num)]
                    else:
                        print("输入错误")
                        continue
                    modification_studentinfo(student,user_info)
            else:
                break
    

    相关文章

      网友评论

          本文标题:day13作业

          本文链接:https://www.haomeiwen.com/subject/pkvpzftx.html