**
代码理解
**
inheritance.py
class Employee:
def __init__(self, name, department, title, salary):
self.name = name
self.department = department
self.title = title
self.salary = salary
def __repr__(self):
return f'<员工:{self.name}>'
def working(self):
print(f'员工{self.name}在工作')
class Developer(Employee): //继承于那个类括号里写那个类
def __init__(self, name. department, title, salary, skills):
Employee.__init__(self, name, department, title, salary) //或者super.__init__(...)
self.skills = skills
class Accoutant(Employee):
def __init__(self, name, department, title, salary, certification)"
Employee.__init__(self, name, department, title, salary)
self.certificatoin = certification
if __name__ =='__main__':
d = Development('Tom', '技术部', '高级工程师', 13000, ['Python', 'Flask'])
print(d.name)
d.working()
a = Accountant('Mary', '财务部', '会计师', 9800, '会计从业i资格证')
print(a.certifacation)