gitmyhub

python-docx

Python ★ 5.7k updated 1y ago

Create and modify Word documents with Python

python-docx is a Python library for creating, reading, and editing Microsoft Word .docx files entirely from code. Add paragraphs, headings, tables, and images without opening Word.

Pythonsetup: easycomplexity 2/5

python-docx is a Python library for reading, creating, and modifying Microsoft Word files in the .docx format. Word files from 2007 onward use this format, so the library covers any modern Word document.

The library lets you open an existing document and read its contents, add new paragraphs, headings, tables, images, and other elements, then save the result as a new or updated .docx file. The README shows a minimal example: creating a blank document, adding a paragraph, saving it, then reopening it and reading the paragraph back out. More detailed documentation is available on the project's ReadTheDocs site.

Installation is a single command via pip, the standard Python package manager. The library is useful for any situation where you want to generate Word documents from code rather than opening Word manually. Common use cases include generating reports, filling in document templates, or extracting text from Word files for further processing. The README itself is brief and points to external documentation for full usage details.

Where it fits