pythondocx在文档末尾添加一个表

2024-09-28 19:25:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我必须在每个文档的末尾添加一个表。但是文本永远不会在文档末尾结束

有没有关于如何在文档末尾追加此表的提示?Thnx

txt = ["xxxxxx","yyyyyy","zzzzzz"]
d = Document(os.path.join(path,i))
table = d.add_table(rows=3, cols=1)
for j in range(3):
    row = table.rows[j]
    row.cells[0].text = txt[j]
d.save(os.path.join(path,i))

输出: enter image description here


Tags: path文档文本txtostabledocumentrows