Python Development()不接受参数?
因此,我不断收到一个错误,比如说“development=development(name,manager,tel,notice)”,说development()不带任何参数,我尝试更改方法和所有内容,但没有成功。这也是类继承的方式吗?因为我不太确定这是否是您的方法。您需要一个构造函数或类的Python Development()不接受参数?,python,Python,因此,我不断收到一个错误,比如说“development=development(name,manager,tel,notice)”,说development()不带任何参数,我尝试更改方法和所有内容,但没有成功。这也是类继承的方式吗?因为我不太确定这是否是您的方法。您需要一个构造函数或类的\uuuu init\uuuu()方法。如果不指定显式构造函数,解释器就无法知道类应该接受多少参数。您需要添加如下内容: class Club: keyword = ""
\uuuu init\uuuu()
方法。如果不指定显式构造函数,解释器就无法知道类应该接受多少参数。您需要添加如下内容:
class Club:
keyword = ""
def introduce(cls):
print('[%s Club]'%cls.keyword)
def printInfo(self):
print("Hello we are %s ."%self.name)
print("leader:",self.manager)
print("leader tel number",self.tel)
class Development(Club):
def special(self,notice):
print(self.notice)
name=input()
manager=input()
tel=input()
notice=input()
development= Development(name,manager,tel,notice)
development.introduce()
development.printInfo()
development.sepcial()
class Development(Club):
def __init__(name, manager, tel, notice):
self.name = name
self.manager = manager
self.tel = tel
self.notice = notice
def special(self,notice):
print(self.notice)