Python Can';t使用抽象方法getAdminCharge、getFinesPerDay实例化抽象类项。不能的 无法执行代码,尝试打印C1,无法使用抽象方法getAdminCharge、GetFineSperDay实例化抽象类项如果要实际实例化项,请说明

Python Can';t使用抽象方法getAdminCharge、getFinesPerDay实例化抽象类项。不能的 无法执行代码,尝试打印C1,无法使用抽象方法getAdminCharge、GetFineSperDay实例化抽象类项如果要实际实例化项,请说明,python,python-3.x,class,oop,abstract,Python,Python 3.x,Class,Oop,Abstract,Can';t使用抽象方法getAdminCharge、getFinesPerDay实例化抽象类项。不能的 无法执行代码,尝试打印C1,无法使用抽象方法getAdminCharge、GetFineSperDay实例化抽象类项如果要实际实例化项,请说明为什么在此处使用abstractmethod和ABC? from abc import ABC, abstractmethod import datetime from typing import List class Item(ABC):

Can';t使用抽象方法getAdminCharge、getFinesPerDay实例化抽象类项。不能的
无法执行代码,尝试打印C1,无法使用抽象方法getAdminCharge、GetFineSperDay实例化抽象类项如果要实际实例化
,请说明为什么在此处使用
abstractmethod
ABC
from abc import ABC, abstractmethod
import datetime
from typing import List

class Item(ABC):
    _loanDuration = 14    

    @classmethod
    def getLoanDuration(cls):
        return cls._loanDuration
    
    @classmethod
    def setLoanDuration(cls, newDuration):
        cls._loanDuration = newDuration

    def __init__(self, title: str, yearPublished: int, cost: float):
        self._title = title
        self._yearPublished = yearPublished
        self._cost = cost

    @property
    def title(self):
        return self._title

    @property
    def yearPublished(self):
        return self._yearPublished

    @property
    def cost(self):
        return self._cost

    @abstractmethod
    def getAdminCharge(self):
        return self.getAdminCharge
    
    @abstractmethod
    def getFinesPerDay(self):
        return self.getAdminCharge
    
    def lostCharges(self):
        return self.getAdminCharge() + self._cost

    def __str__(self):
        return f"{self._title} {self._yearPublished} Cost: ${self._cost}"
    
C1 = Item("Asia Food And Culture","2019","30")
    
print(C1)