首页 > 代码库 > python编程快速上手之第13章实践项目参考答案(13.6.2)

python编程快速上手之第13章实践项目参考答案(13.6.2)

#! python3
# encoding: UTF-8 
import os
import docx
from docx import Document
from docx.shared import Pt
from docx.shared import Inches
os.chdir(C:\\Users\\Administrator\\Python35-32)
doc = docx.Document(InvitationLetter.docx)
guests = open(guests.txt)
doc.add_page_break()
font_name = uBrush Script MT
for n in guests:
  doc.add_paragraph(doc.paragraphs[0].text)
  doc.add_paragraph(n)
  doc.add_paragraph(doc.paragraphs[2].text)
  doc.add_paragraph(doc.paragraphs[3].text)
  doc.add_paragraph(doc.paragraphs[4].text)
  doc.add_page_break()
  
doc.save(InvitationLetter2.docx)

 

python编程快速上手之第13章实践项目参考答案(13.6.2)