【发布时间】:2017-01-25 00:06:59
【问题描述】:
我想知道我落后的地方,寻求您的建议..
class Student_Record(object):
def __init__(self,s):
self.s="class_Library"
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(self)
我收到这个错误..
TypeError: init() 只需要 2 个参数(给定 1 个)
【问题讨论】:
-
Student_Record().. 忘记传递参数(对于s)。或者可能有一个参数太多?此外,rec.Student_details(self)是错误的,因为 Python 自动 将self参数提供给方法。 -
代码说明Python基础要强制执行:除了报错,程序本身的逻辑也要调整
标签: python