获取 word docx 中的表数
Get number of tables in word docx
我正在使用 python-docx 从 .doc(x) 文件中解析 tables。我没有看到计算文件中 table 数量的方法。我想遍历每个 table 的特定单元格条目
“Document”对象上有一个“table”属性,它应该允许您遍历文档中的所有 tableS。
https://python-docx.readthedocs.io/en/latest/api/document.html#id1
Word文档中表格的简单计数可以这样做:
document = Document("having-tables.docx")
table_count = len(document.tables)
如果您想遍历文档中的所有表格,它是:
for table in document.tables:
# ---do_something_to(table)---
我正在使用 python-docx 从 .doc(x) 文件中解析 tables。我没有看到计算文件中 table 数量的方法。我想遍历每个 table 的特定单元格条目
“Document”对象上有一个“table”属性,它应该允许您遍历文档中的所有 tableS。
https://python-docx.readthedocs.io/en/latest/api/document.html#id1
Word文档中表格的简单计数可以这样做:
document = Document("having-tables.docx")
table_count = len(document.tables)
如果您想遍历文档中的所有表格,它是:
for table in document.tables:
# ---do_something_to(table)---