C
C
comandante_ktc2021-12-27 20:15:42
Python
comandante_ktc, 2021-12-27 20:15:42

Finding an element in a table with docx python?

Thank you, but I ran into a problem in the future and tried to figure out why this code outputs not 4, but 3


from docx import Document

document = Document('1.docx')
table = document.tables[0]
cell = table.cell(1, 1)
print(cell.text)
Output: 3

61c9d6c64bd1b573736497.png
How did not change the value, the same thing,
here too xs

def know_rasp(table_num,cell_x,cell_name,doc):
cell_y = 1
num_1 = 1
message = []
while cell_y != 8:

table = doc.tables[table_num]
cell = table.cell(cell_y, cell_x)

text_1 = cell.text

message_append = str(num_1) + '. '+ str(text_1)
message.append(message_append)

cell_y += 1
num_1 += 1
print(message)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question