7_22 day 25 33min接口继承
接口就是一个函数,继承是定义一个基类,基类一个方法定义成装饰器形式
import abc
class All_file(metaclass=abc.ABCMeta):
@abc.abstractmethod
def read(self):
pass
@abc.abstractmethod
def write(self):
pass
class Disk(All_file):
def read(self):
print('disk read')
def write(self):
print('disk write')
class Cdrom(All_file):
def read(self):
print('cdrom read')
def write(self):
print('cdrom write')
class Mem(All_file):
def read(self):
print('mem read')
def write(self):
print('mem write')
#
m1=Mem()
m1.read()
m1.write()