-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
my simple code is :
import datetime
import docx
from docx.oxml import OxmlElement
from docx.oxml.ns import qn
from docx import Document
from docx.shared import Inches
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.shared import Pt
from docx.shared import Cm
from docx import section
import os
import sys
lastday=str(datetime.date.today()-datetime.timedelta(days=1))
doc=Document('C:\Users\Administrator\Desktop\python test\update_test\\sample.docx')
for paragraph in doc.paragraphs:
if 'Report_name' in paragraph.text:
print paragraph.text
titlename='Test'+' '+lastday
paragraph.text = titlename
filename=lastday+' '+'test.docx'
filepath = os.path.join(r'C:\Users\Administrator\Desktop\python test\update_test', filename)
doc.save(filepath)
the old text is Report_name, it is in bold but when I finished changing it change to non-bold how can I keep the style
Metadata
Metadata
Assignees
Labels
No labels