主页
Python
Python abc 模块
demo_ref_module_abc_basic
运行 ❯
×
更改方向
保存代码
更改主题
from abc import ABC, abstractmethod class Shape(ABC): @abstractmethod def area(self): pass class Square(Shape): def __init__(self, s): self.s = s def area(self): return self.s * self.s sq = Square(3) print(isinstance(sq, Shape)) print(sq.area())
True
9