给表的单元格赋值

from  docx  import  Document
from  docx  import  WD_PARAGRAPH_ALIGNMENT

w=Documeent(r'F:word练习a.docx')

#第一种方法
t=w.add_table(3,3)
t.cell(0,0).text='李先生'

#第二种方法
段落=t.cell(0,1).paragraphs[0]
段落.text='王二麻子'
段落1=t.cell(0,1).add_paragraph('第二个段落居中')
段落1.alighment=WD_PARAGRAPH_ALIGNMENT.CENTER    #居中对齐
原文地址:https://www.cnblogs.com/luckiness/p/13237106.html