AbsReaderWriter.py 415 B

12345678910111213141516171819202122
  1. from abc import ABC, abstractmethod
  2. class AbsReaderWriter(ABC):
  3. """
  4. 同时支持二进制和文本读写的抽象类
  5. """
  6. def __init__(self):
  7. # 初始化代码可以在这里添加,如果需要的话
  8. pass
  9. @abstractmethod
  10. def read(self, path: str, mode="text"):
  11. pass
  12. @abstractmethod
  13. def write(self, content: str, path: str, mode="text"):
  14. pass