def output(self, title: str, description: str) -> None: self.title = title self.description = description output: dict[str, str] = { "title": self.title, "description": self.description } with open("output.json", "w") as f: json.dump(output, f, indent=4) # `AbstractOutputFile`を継承 class HtmlOutputFile(AbstractOutputFile): def output(self, title: str, description: str) -> None: text: str = "<html>\n" text += "<head>\n" text += "<title>" + title + "</title>\n" text += "</head>\n" text += "<head>\n" text += "<body><p>" + description + "</p></body>\n" text += "</html>\n" with open("output.html", mode="w") as f: f.write(text) shimakaze-soft 50