写入Markdown文件。 参数: - file_path (str): 文件路径。 - data (str): 要写入的Markdown内容。 - mode (str): 写入模式,默认为 'a'(追加模式),可以选择 'w'(覆盖模式)。 - encoding (str): 写入文件的编码格式,默认为 'utf-8'。
(file_path, data, mode, encoding='utf-8')
| 686 | |
| 687 | |
| 688 | def write_markdown(file_path, data, mode, encoding='utf-8'): |
| 689 | """ |
| 690 | 写入Markdown文件。 |
| 691 | |
| 692 | 参数: |
| 693 | - file_path (str): 文件路径。 |
| 694 | - data (str): 要写入的Markdown内容。 |
| 695 | - mode (str): 写入模式,默认为 'a'(追加模式),可以选择 'w'(覆盖模式)。 |
| 696 | - encoding (str): 写入文件的编码格式,默认为 'utf-8'。 |
| 697 | """ |
| 698 | logger.info(f"写入Markdown文件: {file_path}") |
| 699 | with open(file_path, mode, encoding=encoding) as f: |
| 700 | f.write(data) |