{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "vscode": { "languageId": "plaintext" } }, "outputs": [], "source": [ "from docx import Document\n", "# 读取word中表格,处理成表头加行的形式\n", "def read_table_from_word(file_path):\n", " all_rows = []\n", " doc = Document(file_path)\n", " for i, table in enumerate(doc.tables):\n", " for row in table.rows:\n", " cells_text = [cell.text.replace('\\n', '') for cell in row.cells]\n", " all_rows.append(cells_text)\n", " new_all_rows=[]\n", " i = 0\n", " # 合并跨页的表格行\n", " while i