无法识别“付款”属性

时间:2020-06-15 19:27:37

标签: python class methods attributes

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'
有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

您似乎从self.pay = pay中丢失了__init__