Reading/Writing MS Word files in Python

流过昼夜 提交于 2019-11-26 16:26:53
auramo

I'd look into IronPython which intrinsically has access to windows/office APIs because it runs on .NET runtime.

Damian

See python-docx, its official documentation is available here.

This has worked very well for me.

markling

If you only what to read, it is simplest to use the linux soffice command to convert it to text, and then load the text into python:

doc (Word 2003 in this case) and docx (Word 2007) are different formats, where the latter is usually just an archive of xml and image files. I would imagine that it is very possible to write to docx files by manipulating the contents of those xml files. However I don't see how you could read and write to a doc file without some type of COM component interface.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!