使用Python的word文档的页数(Number of pages of a word document with Python)
有没有办法用Python有效地获得word文档(.doc,.docx)的页数?
对于.odt文件?
我想将它用于基于Linux上的Web2py的Web应用程序。
谢谢 !
Is there a way to get efficiently the number of pages of a word document (.doc, .docx) with Python ?
And for an .odt file ?
I want to use this for a web application based on Web2py on Linux.
Thank you !
原文:https://stackoverflow.com/questions/12964580
2019-10-23 16:10
满意答案
你可以读取值
CountValue
来自docx包中的docProps / app.xml或
在odt包中形成meta.xml。
如果这些值不存在(它们是可选的),你必须计算整个文档,实际上执行渲染,这要困难得多
You can read the value
CountValue
from docProps/app.xml in the docx package or
form meta.xml in odt package.
If these values do not exist (they are optional), you have to make a calculation of the entire document, in fact perform rendering, that much more difficult
2012-10-19
相关问答
有几种方法可以使用Python创建Word文档: 使用COM自动化使用MS Word对象模型(使用pywin32 )创建文档。 http://python.net/crew/pirx/spam7/ 使用Python自动化OpenOffice: http : //wiki.services.openoffice.org/wiki/Python 如果rtf格式正常,请使用PyRTF库: http ://pyrtf.sourceforge.net/ 编辑: 由于COM不可能,所以我提出以下建议(受@ k...
尝试之后,我设法将脚本记录到Python(使用Pywin32