<分区>
我是 Python 新手。我一直在关注有关 python 类的在线教程,但我遇到了一个奇怪的错误。
我不知道我做了什么。
下面是我的代码:
class StudentData:
"Contains information of all students"
studentNumber = 0;
def _init_(self,name,age,marks):
self.name = name;
self.age = age;
self.marsk = marks;
def displayStudentNUmber(self):
print 'Total Number of students = ',studentNumber;
def displayinfo(self):
print 'Name of the Student: ',name;
print 'Age of the Student: '.age;
print 'Marks of the Student: '.marks;
student1 = StudentData('Ayesha',12,90)
student2 = StudentData('Sarah',13,89)
print "Student number in case of student 1",student1.displayStudentNumber();
print "Information of the Student",student1.dispalyinfo();
print "Student number in case of student 1",student2.displayStudentNumber();
print "Information of the Student",student2.dispalyinfo();
下面是错误:
Traceback (most recent call last): File "main.py", line 14, in student1 = StudentData('Ali',12,90) TypeError: this constructor takes no arguments
任何人都可以解释为什么我会收到此错误。
对不起,一个蹩脚的问题:(