利用docx中的Document模块,若未安装,则用pip install python-docx先安装。
from docx import Document # 获取word文档 doc = Document(file_name) value = "被替换的文字"