学Python,用RPA
艺赛旗RPA2020.1版本 正在免费下载使用中,欢迎下载使用
www.i-search.com.cn
功能描述:
提取 docx 格式 Word 文档中所有批注。
from zipfile import ZipFile
from re import findall
fn = r"带批注的测试文件.docx"
with ZipFile(fn) as fp:
try:
content = fp.read(“word/comments.xml”).decode(“utf-8”)
except:
content = ‘’
if not content:
print(“这个文档没有批注”)
else:
for comment in findall(r"<w:t>(.*?)</w:t>", content):
print(comment)
运行结果:
交易码
网址