学习PYTHON时,按照书上练习出现异常
classWorker:def_init_(self,name,pay):self.name=nameself.pay=paydeflastName(self):retu...
class Worker:
def _init_(self,name,pay):
self.name = name
self.pay = pay
def lastName(self):
return self.name.split()[-1]
def giveRaise(self,percent):
self.pay *= (1.0 + percent)
bob = Worker('Bob Smith',50000)
出现Traceback (most recent call last):
File "<pyshell#80>", line 1, in <module>
bob = Worker('Bob Smith',50000)
TypeError: this constructor takes no arguments异常。 展开
def _init_(self,name,pay):
self.name = name
self.pay = pay
def lastName(self):
return self.name.split()[-1]
def giveRaise(self,percent):
self.pay *= (1.0 + percent)
bob = Worker('Bob Smith',50000)
出现Traceback (most recent call last):
File "<pyshell#80>", line 1, in <module>
bob = Worker('Bob Smith',50000)
TypeError: this constructor takes no arguments异常。 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |