(md_path, lines_to_add)
| 46 | |
| 47 | |
| 48 | def update_log(md_path, lines_to_add): |
| 49 | with open(md_path, "r", encoding="utf-8") as f: |
| 50 | original_content = f.readlines() |
| 51 | # 在脚本名称后插入新的更新段. |
| 52 | updated_content = original_content[:1] + lines_to_add + original_content[1:] |
| 53 | with open(md_path, "w", encoding="utf-8", newline='\n') as f: |
| 54 | f.writelines("\n" + line + "\n" if not line.endswith("\n") else line for line in updated_content) |
| 55 | |
| 56 | |
| 57 | if __name__ == "__main__": |