python面向对象-抽象类
一、抽象类1.abc模块提供了ABC类用于定义抽象基类2.抽象基类是一种特殊的类它是不能被实例化的3.抽象类只能被用来定义其他的基类。4.抽象类中可以使用abstractmethod装饰器标记的抽象方法只用于定义不进行实现二、其他1.创建一个空类class Dog:pass2.创建一个对象d dog()3.self的使用class Dog:def print(self):pass4.__init__初始化magic方法5.调用父类的__init__方法class Person(object):def __init__(self,name,id_number):self.name nameself.id_number id_numberdef display(self):print(fname:{self.name})print(fid:{self.id_number})def details(self):print(fmy name is {self.name})print(fid numer is {self.id_number})#子类class Employee(Person):def __init__(self,name,id_number,salary,post):self.salary salaryself.post post#调用父类的__init__Person.__init__(self,name,id_number)def details(self):print(fMy name is {self.name})print(fId_number is {self.id_number})print(fPost:{self.post})a Employee(Rahul,88888,20000,Intern)a.display()a.details()6.多态