在word中替换关键文字
from win32com.client import Dispatch
import time# def tihuan(before,content):
# word = Dispatch('Word.Application')
# doc = word.Documents.Open(r"E:\sxx\test2.docx")
# word.Selection.Find.Execute(before, False, False, False, False, False, True, 1, True, content, 2)f=open("mingdanB.txt")
i=0
for each in f:listeach=each.split("\t")time.sleep(1)word = Dispatch('Word.Application')doc = word.Documents.Open(r"E:\sxx\test.docx")word.Selection.Find.Execute("朱红", False, False, False, False, False, True, 1, True, listeach[0], 2)word.Selection.Find.Execute("SHA603", False, False, False, False, False, True, 1, True, listeach[1], 2)word.Selection.Find.Execute("2016.3.26-2017.12.31", False, False, False, False, False, True, 1, True, listeach[2], 2)word.Selection.Find.Execu