使用python讀取word,寫入execl
阿新 • • 發佈:2018-03-02
bubuko win name 圖片 doc table -- sta mage
#coding:utf-8 import os import win32com from win32com.client import Dispatch,constants from docx import Document #def getTbl def parse_docx(f,title): d = Document(f) for t in d.tables: ‘‘‘獲取需要的表‘‘‘ tbTitle = t.cell(0, 0).text if title == tbTitle: columnLen= len(t.columns) for i in range(0,columnLen): for row in t.rows: print(row.cells[i].text) print("------------") #print(t.cell(0, 0).text) #t = d.tables[10] #print(t) #print(t.cell(0,0).text) if __name__ == "__main__": f = "123.docx" parse_docx(f,"內科")
使用python讀取word,寫入execl