<100 subscribers
Share Dialog
Share Dialog
from docx import Document from docx.shared import Cm from docx.enum.text import WD_ALIGN_PARAGRAPH import re document=Document(r"g:\CS\Python Scripts\表扬信.docx")
paragraphs=document.paragraphs paragraphs[2].paragraph_format.first_line_indent=Cm(0.74) paragraphs[3].paragraph_format.left_indent=Cm(0.74) paragraphs[4].paragraph_format.alignment=WD_ALIGN_PARAGRAPH.RIGHT paragraphs[4].paragraph_format.right_indent=Cm(2) paragraphs[5].paragraph_format.alignment=WD_ALIGN_PARAGRAPH.RIGHT paragraphs[5].paragraph_format.right_indent=Cm(2)
paragraphs[1].text="小Z同学:"
text=re.sub('陆亦可','大Z',paragraphs[2].text) text=re.sub('她','他',text) paragraphs[2].text=text
paragraphs[3].add_run("向小z同学学习!")
tables=document.tables tables[0].cell(1,0).text="猫粮" tables[0].cell(2,0).text="猫粮" tables[0].cell(3,0).text="猫粮"
document.add_picture('fun.jpg', width=Cm(11.8)) document.save()
from docx import Document from docx.shared import Cm from docx.enum.text import WD_ALIGN_PARAGRAPH import re document=Document(r"g:\CS\Python Scripts\表扬信.docx")
paragraphs=document.paragraphs paragraphs[2].paragraph_format.first_line_indent=Cm(0.74) paragraphs[3].paragraph_format.left_indent=Cm(0.74) paragraphs[4].paragraph_format.alignment=WD_ALIGN_PARAGRAPH.RIGHT paragraphs[4].paragraph_format.right_indent=Cm(2) paragraphs[5].paragraph_format.alignment=WD_ALIGN_PARAGRAPH.RIGHT paragraphs[5].paragraph_format.right_indent=Cm(2)
paragraphs[1].text="小Z同学:"
text=re.sub('陆亦可','大Z',paragraphs[2].text) text=re.sub('她','他',text) paragraphs[2].text=text
paragraphs[3].add_run("向小z同学学习!")
tables=document.tables tables[0].cell(1,0).text="猫粮" tables[0].cell(2,0).text="猫粮" tables[0].cell(3,0).text="猫粮"
document.add_picture('fun.jpg', width=Cm(11.8)) document.save()
No comments yet