from docx import Document

def handle():

path = r'd:\\a.docx' #表格在哪个位置(文件路径)
document = Document(path) #读入表格文件
tables = document.tables #获取文件中所有的表格

print(len(tables)) #获取文件中有几个表格

for table in tables:#遍历每一个表格
for row in table.rows:#从表格第一行开始遍历读取表格数据
for cell in row.cells:#遍历每一个单元格
print(cell.text) #获得单元格的内容

#把每格内容写入的文本中(要加格式UTF-8 不然报错)
with open("d:\\11.txt", "a+", encoding='utf-8') as f:
f.writelines(cell.text + "\n")



if __name__ == '__main__':
handle()