Python 3.x PPTX找不到占位符

时间:2019-09-13 13:48:44

标签: python python-3.x data-visualization python-pptx

所以我的代码是:

from pptx import Presentation

prs = Presentation('template.pptx')

title_slide_layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(title_slide_layout)
title = slide.shapes.title
subtitle = slide.placeholders[1]

title.text = "Python 3.6 - Turtle Race"
subtitle.text = "Data Analytics&Visualization with random generated data"


for placeholder in prs.slide_layouts[4].placeholders:
    print('%d %s' % (placeholder.placeholder_format.idx, placeholder.name))

slide = prs.slides.add_slide(prs.slide_layouts[4])
littleTitle = slide.placeholders[1]

littleTitle.text('Comparison of Winning times and pieces of wins')

prs.save("visualiztaion.pptx")

我的输出是(有错误):

0 Title 1
1 Text Placeholder 2
2 Content Placeholder 3
3 Text Placeholder 4
4 Content Placeholder 5
10 Date Placeholder 6
11 Footer Placeholder 7
12 Slide Number Placeholder 8
Traceback (most recent call last):
  File "D:/!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!_!Piton/turtleRace/presentationMaker.py", line 34, in <module>
    littleTitle.text('Comparison of Winning times and pieces of wins')
TypeError: 'str' object is not callable

Process finished with exit code 1

Image of my project

您可以看到我在项目中拥有所有推荐的文件,如果需要,我可以发送我的项目解释器的图片。

所以我的问题基本上是如何将文本插入0 Title 11 Text Placeholder 2

所以大多数情况下,我只想解决并传递错误,因为我必须使此代码起作用。

所以请帮帮我。

0 个答案:

没有答案