没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
试读
2页
1.Word文档如下: 2.代码 # -*- coding: UTF-8 -*- from docx import Document def readSpecTable(filename, specText): document = Document(filename) paragraphs = document.paragraphs allTables = document.tables specText = specText.encode('utf-8').decode('utf-8') for aPara in paragraphs: if aPara.text ==
资源推荐
资源详情
资源评论
python读取读取word 中指定位置的表格及表格数据中指定位置的表格及表格数据
1.Word文档如下:
2.代码
# -*- coding: UTF-8 -*-
from docx import Document
def readSpecTable(filename, specText):
document = Document(filename)
paragraphs = document.paragraphs
allTables = document.tables
specText = specText.encode('utf-8').decode('utf-8')
for aPara in paragraphs:
if aPara.text == specText:
ele = aPara._p.getnext()
while (ele.tag != '' and ele.tag[-3:] != 'tbl'):
ele = ele.getnext()
if ele.tag != '':
for aTable in allTables:
if aTable._tbl == ele:
for i in range(len(aTable.rows)):
for j in range(len(aTable.columns)):
print(aTable.cell(i, j).text)
if __name__ == '__main__':
readSpecTable('test.docx', '符号约定')
3.结果
符号
符号
含义
数据域取值符号
M
必须填写的域
数据域取值符号
C
某条件成立时必须填写的域
数据域取值符号
资源评论
- kwngde2022-12-05#毫无价值
weixin_38609720
- 粉丝: 3
- 资源: 983
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功