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

后端 未结 3 1582
刺人心
刺人心 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:46

    Your code should be like this..(python indent):

    class Student_Record(object):
    
        def __init__(self,s="class_Library"):
            self.s=s
            print"Welcome!! take the benifit of the library"
    
        def Student_details(self):
            print " Please enter your details below"
            a=raw_input("Enter your name :\n")
            print ("your name is :" +a)
            b=raw_input("Enter your USN :\n")
            print ("Your USN is:" ,int(b))
            c=raw_input("Enter your branch :\n")
            print ("your entered baranch is" +c)
            d=raw_input("Enter your current semester :\n")
            print ("your in the semester",int(d))
    
    rec=Student_Record()
    
    rec.Student_details()
    

    s in def __init__ should have a default value or you can pass a value from rec=Student_Record().

提交回复
热议问题