class Employee:
def __init__(self, first,last, pay):
self.first=first
self.last= last
self.email=first+'.'+last+'@company.com'
def fullname(self):
return '{} {}'.format(self.first,self.last)
def apply_rate(self):
self.pay=int(self.pay * 1.04)
emp_1=Employee('Rehim','Hesimov',50000)
emp_2=Employee('Test','User',60000)
print(emp_1.pay)
emp_1.apply_rate()
print(emp_1.pay)
回溯(最近通话最近):
文件“ C:\ Users \ rehim \ Desktop \ class.py”,第12行,
打印(emp_1.pay)
AttributeError:'Employee'对象没有属性'pay'
有人可以帮我吗?
答案 0 :(得分:0)
您似乎从self.pay = pay
中丢失了__init__
。