mikemaccana/python-docx
来源:互联网 发布:什么是网络主播 编辑:程序博客网 时间:2024/04/27 13:42
Reads, queries and modifies Microsoft Word 2007/2008 docx files.
Python docx
This Project Has Moved!
Python DocX is now part of Python OpenXML. There's all kinds of new stuff, including Python 3 support, sister libraries for doing Excel files, and more. Check out the current Python DocX GitHub and the current Python DocX docs.
Info below is kept for archival purposes. Go use the new stuff!
Introduction
The docx module creates, reads and writes Microsoft Office Word 2007 docx files.
These are referred to as 'WordML', 'Office Open XML' and 'Open XML' by Microsoft.
These documents can be opened in Microsoft Office 2007 / 2010, Microsoft Mac Office 2008, Google Docs, OpenOffice.org 3, and Apple iWork 08.
They also validate as well formed XML.
The module was created when I was looking for a Python support for MS Word .docx files, but could only find various hacks involving COM automation, calling .Net or Java, or automating OpenOffice or MS Office.
The docx module has the following features:
Making documents
Features for making documents include:
- Paragraphs
- Bullets
- Numbered lists
- Document properties (author, company, etc)
- Multiple levels of headings
- Tables
- Section and page breaks
- Images
Editing documents
Thanks to the awesomeness of the lxml module, we can:
- Search and replace
- Extract plain text of document
- Add and delete items anywhere within the document
- Change document properties
- Run xpath queries against particular locations in the document - useful for retrieving data from user-completed templates.
Getting started
Making and Modifying Documents
Just download python docx.
Use pip or easy_install to fetch the lxml and PIL modules.
Then run:
example-makedocument.py
Congratulations, you just made and then modified a Word document!
Extracting Text from a Document
If you just want to extract the text from a Word file, run:
example-extracttext.py 'Some word file.docx' 'new file.txt'
Ideas & To Do List
- Further improvements to image handling
- Document health checks
- Egg
- Markdown conversion support
We love forks, changes and pull requests!
- Check out the [HACKING](HACKING.markdown) to add your own changes!
- For this project on github
- Send a pull request via github and we'll add your changes!
Want to talk? Need help?
Email python-docx@googlegroups.com
License
Licensed under the MIT license
Short version: this code is copyrighted to me (Mike MacCana), I give you permission to do what you want with it except remove my name from the credits. See the LICENSE file for specific terms.
- mikemaccana/python-docx
- python-docx
- Python-docx简介
- 安装 python-docx
- python操作word docx
- Python-docx安装失败
- Python读写docx文件
- python操作docx
- python docx 中文字体设置
- python操作docx文档
- python操作docx文档
- python-docx杂记
- Python docx转PDF
- Python安装docx依赖包
- 解决python-docx打包之后找不到default.docx
- [Python] python-docx 编辑word文档
- python docx库使用样例
- python安装docx和lxml(windows)
- Java中Collections类的排序sort函数两种用法
- C++中double数据类型的内存模型
- 学习Hadoop不错的系列文章
- gcc 编译器参数说明
- VBScript报“找不到指定的模块”的处理方法
- mikemaccana/python-docx
- Lab3 and Lab4
- Lucene多索引搜索
- 字符统计-MAP用法
- 佳和她的四合院 像老北京一样生活
- 学生信息管理系统之万能用户'or''='
- 魔方
- 暑期集训第六天:最大连续和问题
- 从0开始学习emacs