要使用Python从Word文档表中删除空行

时间:2018-10-15 10:34:46

标签: python python-3.x python-2.7

image of requiremnts 这段代码产生的表带有多余的空行,即图像中

   name    des
1)  empty  empty
2)  empty  empty
3)  empty  empty
4)  joi    student
5)  umair  developer
6)  maria  student


name=[joi,umair,maria]
des=[student,developer,student]
table = document.add_table(rows=len(name), cols=2)
hdr_cells = table.rows[0].cells
hdr_cells[0].text = 'name'
hdr_cells[1].text = 'des'
row_cells = table.add_row().cells
document.add_paragraph('')
for Attachments,i in zip(name,des):

    row_cells[0].text = str(name)
    row_cells[1].text = str(des)
document.add_page_break()
document.save('Autodoc.docx')

想要删除空行。我不知道为什么在我的worddoc中甚至会产生这些空行。

0 个答案:

没有答案