读取、创建或修改 Word 文档(.docx)——提取文本、生成报告、批量替换、调整格式。当用户涉及 Word/docx 文件处理时使用。需要本机 Python + python-docx。
Scanned 9/6/2026
Install to Claude Code
npx -y skills add Ducktang123/claude-code-deepseek --skill docx --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Docx?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/ducktang123-docx-claude-code-deepseek)More formats (shields.io, HTML) on the badges page.
---
name: docx
description: 读取、创建或修改 Word 文档(.docx)——提取文本、生成报告、批量替换、调整格式。当用户涉及 Word/docx 文件处理时使用。需要本机 Python + python-docx。
---
# Word 文档处理 (.docx)
用 Python 的 `python-docx` 库读写 Word 文档。通过 Bash/PowerShell 运行 Python 脚本完成。
## 前置
依赖库:`python-docx`(安装包已自动装好;若缺失:`pip install python-docx -i https://pypi.tuna.tsinghua.edu.cn/simple`)。
## 常见任务
### 读取/提取文本
```python
from docx import Document
doc = Document("输入.docx")
for p in doc.paragraphs:
print(p.text)
# 表格
for table in doc.tables:
for row in table.rows:
print([c.text for c in row.cells])
```
### 新建文档
```python
from docx import Document
doc = Document()
doc.add_heading("标题", level=1)
doc.add_paragraph("正文段落。")
doc.add_paragraph("要点", style="List Bullet")
t = doc.add_table(rows=1, cols=2); t.style = "Light Grid Accent 1"
doc.save("输出.docx")
```
### 批量查找替换(保留格式)
遍历 `doc.paragraphs` 与表格单元格,在 `run.text` 上做替换。
## 原则
- 先用临时脚本验证读出来的结构,再做修改。
- 中文字体可设置 `run.font.name` 并配 `w:eastAsia`,避免中文显示异常。
- 处理完告诉用户输出文件路径。
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!
Ultra-compressed communication mode. Cuts token usage ~75% by speaking like caveman while keeping full technical accuracy. Supports intensity levels: lite, full (default), ultra, wenyan-lite, wenyan-full, wenyan-ultra. Use when user says "caveman mode", "talk like caveman", "use caveman", "less tokens", "be brief", or invokes /caveman. Also auto-triggers when token efficiency is requested.