我是新的python开发人员,我有句子列表。例如,我去学校,“我想要一辆新车”。如何使用Python将它们中的每一个写入Powerpoint中的新幻灯片?
这是我的代码
from pptx import Presentation
from pptx.util import Inches, Pt
with open("g.txt", 'r') as infile:
for i in infile:
prs = Presentation()
blank_slide_layout = prs.slide_layouts[6]
slide_layout = prs.slide_layouts[SLD_LAYOUT_TITLE_AND_CONTENT]
slide = prs.slides.add_slide(slide_layout)
slide = prs.slides.add_slide(blank_slide_layout)
left = top = width = height = Inches(1)
txBox = slide.shapes.add_textbox(left, top, width, height)
tf = txBox.text_frame
p = tf.add_paragraph()
p.text = i
p.font.size = Pt(40)
prs.save('save.pptx')