python - 在表格中打印文本,留下 n 行和列
问题描述
我需要在离开行 [0] 和列 [0] 的单元格中打印文本。我可以让程序离开行或列,但我不知道如何让它同时离开。
现在我正在这样做,但这只是行,它会在表格中留下第一([0])行来打印文本,但我需要程序同时离开第一([0])列。
docu = docx.Document()
table_x = docu.add_table(rows=5, cols=5)
for row_x in table_x.rows[1:].cells:
row_x = 'hi'
这只会留下 rows[0] 但我需要它同时留下 columns[0] 。
解决方案
for row in table_x.rows[1:]:
for column in row.cells[1:]:
column.text = 'hi'