from abc import abstractmethod,ABCclass BaseProcess(ABC):@abstractmethoddef process_file(self,filepath):passclass ExcelProcess(BaseProcess):def process_file(self,filepath):print("处理excel 方法")class CsvProcess(BaseProcess):def process_file(self,filepath):print("处理CSV 方法")class JsonProcess(BaseProcess):def process_file(self,filepath):print("处理Json 方法")class FileProcess:def __init__(self,pathfile):self.file_path = pathfileself.file_type = pathfile.split(".")[-1]def process_file(self):if self.file_type=="xlsx":ExcelProcess().process_file(self.file_path)elif self.file_type=="csv":CsvProcess().process_file(self.file_path)elif self.file_type=="json":JsonProcess().process_file(self.file_path)if __name__ == '__main__':file_process = FileProcess("one.xlsx")file_process.process_file()file_process = FileProcess("two.csv")file_process.process_file()