文件转化备忘文件

一、makdown文件转化

普通文件转化成makdown文件。采用python来进行转化。就是“add_md_header.py”文件,在位置“H:\Tool_program\markdown加####”。

# 文件: H:\Tool_program\markdown加####\add_md_header.py

import os

# 输入文件路径

input_file = r”H:\Tool_program\markdown加####\input.txt” # 修改为你的文本文件名

# 输出文件路径

output_file = r”H:\Tool_program\markdown加####\output.md” # 输出文件名

# 确保输入文件存在

if not os.path.exists(input_file):

exit(1)

# 处理文件

with open(input_file, “r”, encoding=”utf-8”) as infile, open(output_file, “w”, encoding=”utf-8”) as outfile:

for line in infile:

line = line.strip() # 去掉首尾空格和换行

if line: # 非空行加上

outfile.write(f”#### {line}\n”)

else:

outfile.write(“\n”) # 保留空行

首先,将需要转化的文件内容放在“input.txt”文件里面。

然后运行 a cd H:\Tool_program\markdown加####

b python add_md_header.py

转化完成的文件在”output.md”文件里,然后贴在vscode里。完成。

二、 文字转化成语音文件mp3

首先把文字内容贴在“tts_pyttsx3_mp3.py”文件里。

命令 a cd H:\Tool_program\Text-To-Speech\

b python tts_pyttsx3_mp3.py

语音文件mp3将出现在“Text-To-Speech”文件夹里。完成