ARTS-S python抽象方法抽象类

# coding: utf-8

from abc import ABC, abstractmethod


class AbstractClassExample(ABC):

    def __init__(self, value):
        self.value = value
        super().__init__()

    @abstractmethod
    def do_something(self):
        pass


class A(AbstractClassExample):
    def do_something(self):
        print("hello AAA:{}".format(self.value))


class B(AbstractClassExample):
    def do_something(self):
        print("hello BBB:{}".format(self.value))


if __name__ == '__main__':
    a = A(1)
    a.do_something()
    b = B(2)
    b.do_something()

posted on 2019-06-06 16:42  荷楠仁  阅读(117)  评论(0编辑  收藏  举报

导航