使单元格上中对齐

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()

 

posted @ 2020-07-06 17:54  马蹄哒哒  阅读(203)  评论(0编辑  收藏  举报