使单元格上中对齐

from  docx  import  Document
from  docx.enum.table  import   WD_CELL_VERTICAL_ALIGNMENT
from  docx.enum.text  import  WD_PARAGRAPH_ALIGNMENT
w=Document(r'D:word练习练习.docx')
table=w.tables[0]
cell=table.cell(0,0)

#靠上居中对齐
cell.vertical_alignment=WD_CELL_VERTICAL_ALIGNMENT.TOP
cell.paragraphs[0].alignment=WD_PARAGRAPH_ALIGNMENT.CENTER

w.save()
原文地址:https://www.cnblogs.com/luckiness/p/13256088.html