标签:question 抽象方法 pytho copy res instant typeerror 属性 paper
import abc class CopyBase(metaclass=abc.ABCMeta): @abc.abstractmethod def save(self): pass class CopyPaper(CopyBase): def __init__(self): pass def save(self): print("copy paper") class CopyQuestion(CopyBase): def __init__(self): pass copy_paper = CopyPaper() copy_paper.save() copy_question = CopyQuestion() copy_question.save() result: copy paper Traceback (most recent call last): copy_question = CopyQuestion() TypeError: Can‘t instantiate abstract class CopyQuestion with abstract methods save
标签:question 抽象方法 pytho copy res instant typeerror 属性 paper
原文地址:https://www.cnblogs.com/ybl20000418/p/11494446.html