1 #!/usr/sbin/env python 2 #from new import * 3 4 class worker: 5 def __int__(self, name, pay): 6 self.name = name 7 self.pay = pay 8 def lastname(self): 9 return self.name.split()[-1] 10 def giveRaise(self, percent): 11 self.pay *=(1.0 + percent) 12 bob = worker('Bob Smith',50000) 13 sue = worker('sue leaf',50000) 14 bob.lastname() 15 sue.lastname() 16 sue.giveRaise(.10) 17 sue.pay[root@server1 ~]# python old.py Traceback (most recent call last): File "old.py", line 18, in <module> bob = worker('Bob Smith',50000)TypeError: this constructor takes no arguments
1 回答
- 1 回答
- 0 关注
- 144 浏览
添加回答
举报
0/150
提交
取消