https://github.com/python-openxml/python-docx
Create and modify Word documents with Python
https://github.com/python-openxml/python-docx
Last synced: 3 months 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 12 years ago)
- Default Branch: master
- Last Pushed: 2025-06-17T03:15:11.000Z (5 months ago)
- Last Synced: 2025-09-08T07:47:50.995Z (3 months ago)
- Language: Python
- Size: 43 MB
- Stars: 5,199
- Watchers: 146
- Forks: 1,234
- Open Issues: 695
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.rst
- License: LICENSE
Awesome Lists containing this project
- fucking-awesome-python-cn - python-docx
- 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 - python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats Processing)
- 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-python-resources - GitHub - 47% open · ⏱️ 15.05.2021): (特殊文本格式处理)
- 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 - 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 - python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats Processing)
- awesome-python-cn - python-docx
- Awesome-Python - python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats 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 - Create and modify Word documents with Python (Awesome Python / Specific Formats Processing)
- awesome-python - python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (Specific Formats Processing)
- git-github.com-vinta-awesome-python - python-docx - Reads, queries and modifies Microsoft Word 2007/2008 docx files. (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/)