This commit is contained in:
2025-11-22 18:08:14 +08:00
parent af9a0f6c3c
commit 634343a2ff
9 changed files with 1347 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
import pdfplumber
import os
# 使用当前脚本所在目录
script_dir = os.path.dirname(os.path.abspath(__file__))
pdf_path = os.path.join(script_dir, "2025 APMCM Problem B.pdf")
print(f"Looking for PDF at: {pdf_path}")
print(f"File exists: {os.path.exists(pdf_path)}")
if os.path.exists(pdf_path):
with pdfplumber.open(pdf_path) as pdf:
full_text = ""
for i, page in enumerate(pdf.pages):
text = page.extract_text()
if text:
full_text += f"\n=== Page {i+1} ===\n{text}\n"
print(full_text)
# 保存到文本文件
output_path = os.path.join(script_dir, "problem_text.txt")
with open(output_path, "w", encoding="utf-8") as f:
f.write(full_text)
print(f"\n文本已保存到: {output_path}")
else:
print(f"文件不存在: {pdf_path}")
print(f"当前工作目录: {os.getcwd()}")
print(f"目录内容: {os.listdir('.')}")