https://github.com/python-openxml/python-docx
Create and modify Word documents with Python
https://github.com/python-openxml/python-docx
Last synced: about 1 month ago
JSON representation
Create and modify Word documents with Python
- Host: GitHub
- URL: https://github.com/python-openxml/python-docx
- Owner: python-openxml
- License: mit
- Created: 2013-10-15T14:50:41.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2026-08-01T14:59:42.000Z (4 months ago)
- Last Synced: 2026-10-17T10:19:37.092Z (about 1 month ago)
- Language: Python
- Size: 43.3 MB
- Stars: 5,746
- Watchers: 139
- Forks: 1,322
- Open Issues: 539
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.rst
- License: LICENSE
Awesome Lists containing this project
- awesome-python - python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats Processing)
- awesome-python - python-openxml/python-docx - Create and modify Word documents with Python (Data and Storage / Serialization and Formats)
- awesome-python - python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats Processing)
- fucking-awesome-python-cn - python-docx - :读取,查询以及修改 Microsoft Word 2007/2008 docx 文件。 (资源列表 / 特殊文本格式处理)
- git-github.com-vinta-awesome-python - python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats Processing)
- awesome-python-zh - python-docx - 读取,查询和修改Microsoft Word 2007/2008 docx文件。 (特定格式处理)
- awesome-python-cn - python-docx - :读取,查询以及修改 Microsoft Word 2007/2008 docx 文件。 (资源列表 / 特殊文本格式处理)
- awesome-python - python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats Processing)
- fucking-awesome-python - :octocat: python-docx - :star: 3688 :fork_and_knife: 979 - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats Processing)
- awesome-python-resources - GitHub - 47% open · ⏱️ 15.05.2021): (特殊文本格式处理)
- fucking_awesome_python - :octocat: python-docx - :star: 572 :fork_and_knife: 226 - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats Processing)
- awesome-data-analysis - Python-docx - Reads and writes Word documents. (📦 Additional Python Libraries / Documentation & File Processing)
- python-awesome - python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats Processing)
- awesome-python - python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats Processing)
- awesome-python - python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats Processing)
- awesome-python - python-docx - Create and modify Word documents with Python ` 📝 a month ago` (Specific Formats Processing [🔝](#readme))
- awesome-python - python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats Processing)
- fucking-awesome-python - python-docx - Creates, reads, and updates Microsoft Word (.docx) files. (Projects / File Format Processing)
- awesome-python - python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats Processing)
- awesome-python - python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats Processing)
- github-ultimate-repos - python-openxml/python-docx - | ⭐ 5,749★ | 🍴 1,324 | 💻 `Python`🔗 <https://github.com/python-openxml/python-docx>📝 Create and modify Word documents with Python⚙️ `CPython C-API binding -> vectorized NumPy ndarray broadcasting -> SIMD/BLAS numerical linear algebra -> computational pipeline execution -> serialized analytical output.` (📜 Master Categorized Repository Directory (100% Clickable Links) / [55] PYTHON ECOSYSTEM, DATA SCIENCE, SCIENTIFIC COMPUTING & ANALYTICS)
- Python-Awesome - python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats Processing)
- awesome-python - python-docx - <img src="assets/star.png" width="16" /> 1565 <img src="assets/license.png" width="16" /> [MIT](https://api.github.com/licenses/mit)\- Create and modify Word documents with Python (Awesome Python / Specific Formats Processing)
README
# python-docx
*python-docx* is a Python library for reading, creating, and updating Microsoft Word 2007+ (.docx) files.
## Installation
```
pip install python-docx
```
## Example
```python
>>> from docx import Document
>>> document = Document()
>>> document.add_paragraph("It was a dark and stormy night.")
>>> document.save("dark-and-stormy.docx")
>>> document = Document("dark-and-stormy.docx")
>>> document.paragraphs[0].text
'It was a dark and stormy night.'
```
More information is available in the [python-docx documentation](https://python-docx.readthedocs.org/en/latest/)