.docx 支持
from docx import Documentdef read_docx_file(filepath):"""读取 docx 文件内容"""try:doc = Document(filepath)paragraphs = []for para in doc.paragraphs:if para.text.strip():paragraphs.append(para.text)for table in doc.tables:for row in table.rows:for cell in row.cells:if cell.text.strip():paragraphs.append(cell.text)return '\n'.join(paragraphs)except Exception as e:print(f"❌ 读取 docx 失败 {filepath}: {e}")return ""
.pdf 支持
- 还没学
