python - 基于python-docx,在特定文本python之后创建表
问题描述
我在 python 中看到了用于处理 word 文件的 python-docx 文档。对于本教程,我可以add_table
在最后一行中使用创建表。
from docx import Document
from docx.shared import Inches
document = Document()
table = document.add_table(rows=1, cols=3)
当我检测到特定单词create table after line时,我想创建表。如何修改我的代码?
document = Document('./my_document.docx')
start = "create the table after line"
for p in document.paragraphs:
if(start in p.text):
## Create the table in here
p.add_table(nrows=2, cols=3)
解决方案
推荐阅读
- arrays - 使用 ReactJS (typeScript) 匹配类型 .Net Core
- python - Python - 嵌套列表中二进制搜索算法的时间复杂度
- r - R:生存分析广义伽玛参数拟合置信区间计算
- r - Meta分析流程图
- c++ - C++14和C++17的默认构造函数调用区别
- functional-programming - 在 RXJS 中执行“有条件的压缩”更简单/更惯用的方法?
- sql - 00907. 00000 - “缺少右括号”无法创建此表?
- split - SAS ...有一个包含两行数据的字符串,试图只获取第二行
- javascript - 为什么 bigInt 在计算时会给出不同的结果。pow() (使用 npm 大整数)?如何解密给定的数字?
- angular2-template - 如何在 click Handler 函数上调用 AG-Grid 的 gridready 事件