1 #!/usr/bin/env python 2 #抽象方法抽象类 3 import abc 4 class Foo(metaclass=abc.ABCMeta): 5 def f1(self): 6 raise Exception(".....") 7 def f2(self): 8 pass 9 @abc.abstractmethod 10 def f3(self): 11 pass 12 13 class Bar(Foo): 14 def f1(self): 15 print("....") 16 17 def f3(self):#f3必须有 18 print("...")