from docx import Document w=Document(r'F:word练习表格.docx') table_1=w.tables[0] #删除行 print(len(table_1.rows)) row2=table_1.rows[1] row2._element.getparent().remove(row2._element) print(len(table_1.rows)) #删除列 col=table_1.table.columns[1] for cell in col.cells: cell._element.getparent().remove(cell._element) w.save(r'F:word练习删除表格的行或者列.docx')