ARTS-S python抽象方法抽象类

时间:2019-06-06 16:56:35   收藏:0   阅读:86
# 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()

原文:https://www.cnblogs.com/zhouyang209117/p/10985828.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!