问题
I tried to read .odt using python with "odfpy" library, but it still doesn't work. Could you suggest me how to read .odt file using python or give me a simple source code.
Thank you
回答1:
First install odfpy library then,
In [21]: from odf import text, teletype
...: from odf.opendocument import load
...:
...: textdoc = load("your.odt")
...: allparas = textdoc.getElementsByType(text.P)
...: teletype.extractText(allparas[0])
...:
Out[21]: 'Hello World!'
来源:https://stackoverflow.com/questions/51054770/how-to-read-odt-using-python