oikoumene

提取表格

import docx
from docx import Document #导入库

path = \'123.docx\' #文件路径
document = Document(path) #读入文件
tables = document.tables #获取文件中的表格集

for table in tables[:]:
    for i, row in enumerate(table.rows[:]):   # 读每行
        row_content = []
        for cell in row.cells[:]:  # 读一行中的所有单元格
            c = cell.text
            row_content.append(c)
        print (row_content) #以列表形式导出每一行数据

 

分类:

技术点:

相关文章:

  • 2021-12-19
  • 2021-08-15
  • 2021-12-03
  • 2021-09-11
  • 2021-12-19
  • 2021-08-13
  • 2021-12-19
猜你喜欢
  • 2021-11-19
  • 2021-06-22
  • 2021-10-21
  • 2021-08-26
  • 2021-11-29
  • 2021-04-04
  • 2021-08-09
相关资源
相似解决方案