Aug-30-2023, 03:42 AM
the following assumes the actual text you want to replace is "Message"
wrote on the fly, I have not tested this code
wrote on the fly, I have not tested this code
import fileinput with open('C:/01/File_replace/Email_Body.txt','r') as infile: replacement_text = infile.read() with open('C:/01/File_replace/Template_EM.html') as currentfile, open('C:/01/File_replace/Template_EM_New.html','w') as nf: for line in currentfile: if "Message" in line: line.replace("Message", replacement_text) nf.write(line)