python获取word页数_使用Python的word文档的页数(Number of pages of a word document with Python)...

本文介绍了如何使用Python高效地获取Word文档(.doc, .docx)的页数,包括通过docx和odt包读取Page Count值,以及在没有此值时如何进行全文计算。同时提到了在Linux上基于Web2py的Web应用中可能的使用场景。" 132257710,8225484,Python实现LR逻辑回归多输入分类预测详解,"['Python', '机器学习', '逻辑回归', '分类算法', '数据预处理']
摘要由CSDN通过智能技术生成

使用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 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值