运行我的python代码时出现属性错误

时间:2019-12-22 20:44:45

标签: python oop

这是代码

class Employee:
    raise_amt = 1.04

    def __init__(self, first, last, pay):
        self.first = first
        self.last = last
        self.email = first +''+ last + '@company.com'
        self.pay = pay

    def fullname(self):
        return '{} {}'.format(self.first, self.last)

    def apply_raise(self):
        self.pay = int(self.pay * self.raise_amt)

class Developers(Employee):
    pass

dev_1 = Developers ('Nwankwo','Fortune',70000)
dev_2 = Developers ('Test','User', 50000)

#print(dev_1.email)
#print(dev_2.email)

print(dev_1.pay)
dev_1.apply_raise()
print(dev_1.pay)

0 个答案:

没有答案