Python3实现归一化设计的两种方式:

NO1.

import abc


class FClass(metaclass=abc.ABCMeta):
    @abc.abstractmethod
    def send(self):
        pass


class SClass(FClass):
    def send(self):
        print('你好')


son = SClass()
son.send()

NO2.

class FClass:
    def walk(self):
        raise NotImplementedError('未实现该方法!')


class Sclass(FClass):
    pass


son = Sclass()
son.walk()

你可能感兴趣的:(Python)