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()