python-pptx在演示文稿中使用的字体大小

时间:2018-03-31 07:02:58

标签: python python-pptx

如何更改幻灯片上的文字大小。 我不知道为什么,但默认情况下文字大小是32.抱歉我的英文不好。 这是我的代码:

    TEXT = ['''Help on method shuffle in module random:

    shuffle(x, random=None) method of random.Random instance
        Shuffle list x in place, and return None.

        Optional argument random is a 0-argument function returning a
        random float in [0.0, 1.0); if it is the default None, the
        standard random.random will be used.''', '''Help on method choice in         
    module random:

    choice(seq) method of random.Random instance
        Choose a random element from a non-empty sequence.''', '''Help on 
    method randint in module random:

    randint(a, b) method of random.Random instance
        Return random integer in range [a, b], including both end         
    points.''']
    NAMES = ['shuffle', 'choice', 'randint']


    from pptx import Presentation
    prs = Presentation()
    slide_layout = prs.slide_layouts[1]
    for i in range(3):
        slide = prs.slides.add_slide(slide_layout)
        title = slide.placeholders[0]
        content = slide.placeholders[1]
        title.text = NAMES[i]
        content.text = TEXT[i]
    prs.save('test.pptx')

1 个答案:

答案 0 :(得分:1)

此主题在此处的文档中介绍:
http://python-pptx.readthedocs.io/en/latest/user/text.html

简短版本是,如果你想控制文本格式(字体属性),你需要在运行级别(下面一级)工作,这是应用文本格式的地方。

相关问题