from docx import Document
import os

path = '/root/.hermes/cache/documents/doc_ee685c148fd7_版本列车运行机制方案（建议稿）.docx'
doc = Document(path)

text = []
for para in doc.paragraphs:
    if para.text.strip():
        text.append(para.text)

for table in doc.tables:
    for row in table.rows:
        cells = [cell.text.strip() for cell in row.cells]
        if any(cells):
            text.append(' | '.join(cells))

output = '\n'.join(text)
print(output)
print(f"\n\n总字数: {len(output)}")
