__init__() takes exactly 2 arguments (1 given)?

后端 未结 3 1591
刺人心
刺人心 2020-12-12 08:01

I would like to know where am lagging, Looking for your advices..

class Student_Record(object):

    def __init__(self,s):
        self.s=\"class_Library\"
          


        
3条回答
  •  忘掉有多难
    2020-12-12 08:40

    Your Student_Record.__init__() method takes two arguments, self and s. self is provided for you by Python, but you failed to provide s.

    You are ignoring s altogether, drop it from the function signature:

    class Student_Record(object):
        def __init__(self):
            self.s = "class_Library"
            print"Welcome!! take the benifit of the library"
    

    Next, you are calling the method rec.Student_details() passing in an argument, but that method only takes self, which is already provided for you by Python. You don't need to pass it in manually, and in your case the name is not even defined in that scope.

提交回复
热议问题