From 753dbda86fc2065d4dcf83e06bd0c86758e4d088 Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Mon, 30 Jun 2025 16:16:17 +0800 Subject: [PATCH] 'commit' --- dsRag/Test/TestReadDocx.py | 34 ---------------------------------- dsRag/Test/TestReadMathType.py | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 34 deletions(-) delete mode 100644 dsRag/Test/TestReadDocx.py create mode 100644 dsRag/Test/TestReadMathType.py diff --git a/dsRag/Test/TestReadDocx.py b/dsRag/Test/TestReadDocx.py deleted file mode 100644 index f80a1fe1..00000000 --- a/dsRag/Test/TestReadDocx.py +++ /dev/null @@ -1,34 +0,0 @@ -import os -import subprocess - -# 输出文件路径 -output_file = r"d:\output.txt" # 可修改为您需要的路径 - -# 构建命令 -command = r"D:\dsWork\dsProject\dsRag\mtef-go-3\mtef-go.exe -d D:\dsWork\dsProject\dsRag\static\Txt\化学方程式_CHEMISTRY_1.docx -o " + output_file - -try: - # 执行命令并捕获输出,指定编码为utf-8 - result = subprocess.run(command, shell=True, check=True, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - text=True, - encoding='utf-8', - errors='ignore') - - # 将输出写入文件,处理None值情况 - with open(output_file, "a", encoding='utf-8') as f: - if result.stdout: - f.write(result.stdout) - if result.stderr: - f.write(result.stderr) - - print(f"命令执行成功,输出已保存到 {output_file}") - -except subprocess.CalledProcessError as e: - print(f"命令执行失败: {e}") - with open(output_file, "a", encoding='utf-8') as f: - f.write(f"命令执行失败: {e}\n") - if e.stderr: - f.write(f"错误输出: {e.stderr}") - diff --git a/dsRag/Test/TestReadMathType.py b/dsRag/Test/TestReadMathType.py new file mode 100644 index 00000000..3ad4b5fe --- /dev/null +++ b/dsRag/Test/TestReadMathType.py @@ -0,0 +1,16 @@ +import os + + +# 可执行文件路径 +mtef = r'D:\dsWork\dsProject\dsRag\mtef-go-3\mtef-go.exe' +# 源文件路径 +sourceDocx = r'D:\dsWork\dsProject\dsRag\static\Txt\化学方程式_CHEMISTRY_1.docx' +# 输出文件路径 +output_file = r"d:\output.txt" # 可修改为您需要的路径 + +# 构建命令 +command = mtef + r" -w " + sourceDocx + " -o " + output_file +os.system(command) +# 把output.txt里的内容打印出来看看 +with open(output_file, 'r', encoding='utf-8') as file: + print(file.read())