将生成的docx转成zip 重命名,然后查看里面的word/document.xml文件
if re.search(r'ddH2O',r_text):r_text = r_text.replace('ddH2O','')run = p_new.add_run()run.text = 'ddH'run.font.name = 'Arial'run.font.size = Pt(10)run.font.underline = Truerun = p_new.add_run()run.text = '2'run.font.subscript = Truerun.font.name = 'Arial'run.font.size = Pt(10)run.font.underline = Truerun = p_new.add_run()run.text = 'O'run.font.name = 'Arial'run.font.size = Pt(10)run.font.underline = Truerun = p_new.add_run()run.text = ' 'run.font.name = 'Arial'run.font.size = Pt(5)run.font.underline = True
文档中出现H2O