错误消息:ValueError:字典更新序列元素#0的长度为1; 2是必需的

时间:2016-11-16 15:24:29

标签: python python-3.x

运行我的程序时,我收到此错误消息。我不太确定发生了什么,但应该发生的是该程序应该测试一个老学生是否已经注册了课程,如果是这样,新学生将被添加到该课程,否则将创建一个新的课程大学班级注册。

from scipy.odr.odrpack import Output
class Student:

    def __init__ (self,Name,Degree,ID):
        self.courses = []
        self.name = Name
        self.degree = Degree
        self.id = ID

    def takecourse (self,course_Name):
        self.courses.append(course_Name)

    def studentOverview (self):
        print self.name
        print self.id
        print self.degree
        print "Courses:"
        for course in self.courses:
            print course


class University:

    def __init__ (self,Name,City):
        self.registry = {}
        self.name = Name
        self.city = City

    def enrollStudent(self,new_student):
        if not (new_student.degree in self.registry):
            self.registry.update(new_student.degree)
        self.registry(new_student.Degree).append[new_student.id]

    def allstudents(self):
        output = ''
        for key in self.Registry.keys():
            output += (str(key))+ ':\n'
            for output in self.registry[keys]:
                output+='      '+output+'\n'
                output+='\n'
            return output



stud1 = Student('John Doe', 'Computing Science', 5010)
stud2 = Student('Emily Dunne', 'Computing Science', 5011)
stud3 = Student('Marry Atkinson', 'Biology', 5010)
Student.takecourse(stud1,('Computer Programming Principles','WAD'))
Student.takecourse(stud2,('Robotics','HCI'))
Student.takecourse(stud3,('Biology Foundations','Micro Biology'))
Student.studentOverview(stud1)
Student.studentOverview(stud2)
Student.studentOverview(stud3)
uni1 = University('University of Aberdeen','Aberdeen')
uni1.enrollStudent(stud1)         
uni1.enrollStudent(stud2)
uni1.enrollStudent(stud3)
uni1.allstudents()

代码:

S

0 个答案:

没有答案