Appends a formatted summary to a file along with its title. args: title (str): Title of the article. summary (str): Summarized text to save. path (str): File path to save the summary, i.e. 'summaries.txt'
(title, summary, path="summaries.txt")
| 138 | |
| 139 | |
| 140 | def save_summary(title, summary, path="summaries.txt"): # no pytest |
| 141 | """ |
| 142 | Appends a formatted summary to a file along with its title. |
| 143 | |
| 144 | args: |
| 145 | title (str): Title of the article. |
| 146 | summary (str): Summarized text to save. |
| 147 | path (str): File path to save the summary, i.e. 'summaries.txt' |
| 148 | """ |
| 149 | with open(path, "a", encoding="utf-8") as f: |
| 150 | f.write(f"{title}\n{summary}\n{'=' * 60}\n") |
| 151 | |
| 152 | |
| 153 | if __name__ == "__main__": |