Reading/Writing MS Word files in Python

UnkwnTech picture UnkwnTech · Oct 9, 2008 · Viewed 77.4k times · Source

Is it possible to read and write Word (2003 and 2007) files in Python without using a COM object?
I know that I can:

f = open('c:\file.doc', "w")
f.write(text)
f.close()

but Word will read it as an HTML file not a native .doc file.

Answer

Damian picture Damian · Oct 21, 2011

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

This has worked very well for me.