Skip to content
Back to skills

Docx

ASecurity

读取、创建或修改 Word 文档(.docx)——提取文本、生成报告、批量替换、调整格式。当用户涉及 Word/docx 文件处理时使用。需要本机 Python + python-docx。

  • 3 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 6, 2026
ai-agentspythonshellbash

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned September 6, 2026

npx -y skills add Ducktang123/claude-code-deepseek --skill docx --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Docx?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Docx
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ducktang123-docx/badge)](https://www.skillsdirectory.com/skills/ducktang123-docx)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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`,避免中文显示异常。
- 处理完告诉用户输出文件路径。

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…