+
21
-

python有没有根据json章节数据生成pptx的库或插件?

python有没有根据json章节数据生成pptx的库或插件?


网友回复

+
19
-

使用ai的api接口生成json格式的章节信息,然后通过pptx库来替换模板中的占位符就能实现ai一键生成ppt了。

from pptx import Presentation

def replace_placeholders(template_path, output_path, placeholders_data):
    """
    替换 PPT 模板中的占位符内容,并保留样式
    :param template_path: 模板文件路径
    :param output_path: 生成的 PPT 文件路径
    :param placeholders_data: 占位符内容的字典,键为占位符名称,值为要替换的内容
    """
    # 加载模板
    prs = Presentation(template_path)

    # 遍历每一张幻灯片
    for slide in prs.slides:
        # 遍历幻灯片中的每一...

点击查看剩余70%

我知道答案,我要回答