# Python PowerPoint API。 Python PPTX，来自 Aspose.Slides 的 PPT

> 用于处理 Microsoft PowerPoint 文件的 Python 库。 Python PPTX，PPT。创建编辑转换 PPT PPTX PPS POT PPSX PPTM PPSM POTX POTM ODP PDF 和更多格式。

Source: https://products.aspose.com/slides/zh/python-net/
Updated: 2026-08-11



<p><strong>Aspose.Slides for Python via .NET</strong> 是一个强大的类库，用于处理或处理演示文稿。使用此产品，应用程序和开发人员无需第三方应用程序或依赖项即可阅读、编辑或操作以及转换 PowerPoint 演示文稿（PPT、PPTX）和其他格式 (ODP) 的演示文稿。 </p>

<p><strong>Aspose.Slides for Python via。 NET</strong> 提供了这些流行的功能：</p>
<ul>
    <li>加载、打开和查看演示文稿。</li>
    <li>编辑演示文稿。</li>
    <li>将演示文稿转换为 PDF、Word、JPG、HTML、GIF、SVG 和许多其他格式。</li>
    <li>渲染和打印演示文稿。</li>
    <li>加密和解密演示文稿；密码保护演示文稿和删除密码。</li>
    <li>操作演示实体，例如母版幻灯片、形状、图表、图片帧、音频帧、视频帧、OLE、VBA 宏、动画等。</li>
    <li>还有更多功能。</li>
</ul>

<p>Python 是一种非常流行的语言，在常规应用程序、Web 开发、研究和学术任务、数据分析等方面得到了广泛的应用。因此，<strong>Aspose.Slides</strong> 团队很自豪地提供 <strong>Aspose.Slides</strong> strong>Aspose.Slides for Python via .NET</strong> 到 python 社区。 </p>

<div class="diagram1 d1-python">
 <div class="d1-row">
  <div class="d1-col d1-left">
   <header>
    <i class="fa fa-table">
    </i>
    数据处理
   </header>
   <ul>
    <li>
管理图表
    </li>
    <li>
管理 SmartArts
    </li>
    <li>
管理 PowerPoint 形状
    </li>
    <li>
管理 ActiveX 控件
    </li>
    <li>
管理 OleObjects
    </li>
   </ul>
   <header>
    <i class="fa fa-text-width">
    </i>
    文本和段落
   </header>
   <ul>
    <li>
处理文本和格式
    </li>
    <li>
处理超链接文本
    </li>
    <li>
设置占位符类型
    </li>
   </ul>
  </div>

  <div class="d1-col d1-right">
   <header>
    <i class="fa fa-cog">
    </i>
    图形和多媒体
   </header>
   <ul>
    <li>
管理幻灯片过渡
    </li>
    <li>
管理动画效果
    </li>
    <li>
将连接器添加到形状
    </li>
    <li>
旋转和翻转形状
    </li>
    <li>
管理形状的线型
    </li>
   </ul>
  </div>

 </div>

 <div class="d1-logo">
  <img width="70" height="75" alt="Python PowerPoint Processing APIs" src="https://www.aspose.cloud/templates/aspose/img/products/slides/aspose_slides-for-python.svg"/>
  <header>
   Aspose.Slides
  </header>
  <footer>
   <small>
    <em>
     for
    </em>
   </small>
   Python
   <em>via .NET</em>
  </footer>
 </div>

</div>

<div class="diagram1 d1-python">
 <div class="d1-row">
  <div class="d1-col d1-left">
   <header>
    <i class="fa fa-cubes">
    </i>
    视窗
   </header>
   <ul>
    <li>
Windows 7（x64、x86）
    </li>
    <li>
Windows 8、8.1（x64、x86）
    </li>
    <li>
Windows 10（x64、x86）
    </li>
	<li>
和别的
	</li>
   </ul>
  </div>

  <div class="d1-col d1-right">
   <header>
    <i class="fa fa-cubes">
    </i>
    Linux
   </header>
   <ul>
    <li>
Ubuntu
    </li>
    <li>
OpenSUSE
    </li>
    <li>
中央操作系统
    </li>
	<li>
和别的
	</li>
   </ul>
  </div>

 </div>

 <div class="d1-logo">
  <img width="70" height="75" alt="Presentation APIs for Python" src="https://www.aspose.cloud/templates/aspose/img/products/slides/aspose_slides-for-python.svg"/>
  <header>
   Aspose.Slides
  </header>
  <footer>
   <small>
    <em>
     for
    </em>
   </small>
   Python
   <em>via .NET</em>
  </footer>
 </div>

</div>

<div class="diagram1 d2 d1-python">
 <div class="d1-row">
  <div class="d1-col d1-left">
   <header>
    <i class="fa fa-arrows-v">
    </i>
    输入输出
   </header>
   <ul>
    <li>
     <b>
微软PowerPoint：
     </b>
     PPT, PPTX, PPS, POT, PPSX, PPTM, PPSM, POTX, POTM
    </li>
    <li>
     <b>
开发办公室：
     </b>
     ODP
    </li>
    <li>
     <b>
固定布局：
     </b>
     PDF
    </li>
   </ul>
  </div>

  <div class="d1-col d1-right">
   <header>
    <i class="fa fa-mail-forward">
    </i>
    仅输出
   </header>
   <ul>
    <li>
     <b>
固定布局：
     </b>
     PDF, PDF/A, XPS
    </li>
    <li>
     <b>
图片：
     </b>
     JPEG, PNG, BMP, TIFF, GIF
    </li>
    <li>
SVG
    </li>
    <li>
     <b>
网站：
     </b>
     HTML
    </li>
   </ul>
  </div>

 </div>

 <div class="d1-logo">
  <img width="70" height="75" alt="PowerPoint Presentation API" src="https://www.aspose.cloud/templates/aspose/img/products/slides/aspose_slides-for-python.svg"/>
  <header>
   Aspose.Slides
  </header>
  <footer>
   <small>
    <em>
     for
    </em>
   </small>
   Python
   <em>via .NET</em>
  </footer>
 </div>

</div>

<div class="container-fluid features-section bg-gray singleproduct">
 <a class="anchor" id="features" name="features">
 </a>
 <div class="row">
  <div class="container">
   <h2 class="pr-ft">
    高级 Python PowerPoint API 功能
   </h2>
   <p>
   </p>
   <div class="col-lg-4">
    <em class="fa fa-copy ico-blue fa-2x col-lg-2">
    </em>
    <p class="col-lg-10">
     从模板创建或克隆幻灯片
    </p>
   </div>
   <div class="col-lg-4">
    <em class="fa fa-signal ico-blue fa-2x col-lg-2">
    </em>
    <p class="col-lg-10">
     通过 API 处理 PowerPoint 表格
    </p>
   </div>
   <div class="col-lg-4">
    <em class="fa fa-cogs ico-blue fa-2x col-lg-2">
    </em>
    <p class="col-lg-10">
     应用或删除形状上的保护
    </p>
   </div>
   <div class="col-lg-4">
    <em class="fa fa-lock ico-blue fa-2x col-lg-2">
    </em>
    <p class="col-lg-10">
     将 Excel 图表作为 OleObjects 添加到幻灯片
    </p>
   </div>
   <div class="col-lg-4">
    <em class="fa fa-print ico-blue fa-2x col-lg-2">
    </em>
    <p class="col-lg-10">
     支持链接的 OleObjects
    </p>
   </div>
   <div class="col-lg-4">
    <em class="fa fa-text-width ico-blue fa-2x col-lg-2">
    </em>
    <p class="col-lg-10">
     从数据库生成演示文稿
    </p>
   </div>
   <div class="col-lg-4">
    <em class="fa fa-unlock-alt ico-blue fa-2x col-lg-2">
    </em>
    <p class="col-lg-10">
     保护演示文稿和生成的 PDF
    </p>
   </div>
   <div class="col-lg-4">
    <em class="fa fa-print ico-blue fa-2x col-lg-2">
    </em>
    <p class="col-lg-10">
     在物理打印机上打印演示文稿
    </p>
   </div>
   <div class="col-lg-4">
    <em class="fa fa-font ico-blue fa-2x col-lg-2">
    </em>
    <p class="col-lg-10">
     创建和自定义图表
    </p>
   </div>
   <div class="col-lg-12">
    <h2 class="h2title">
     系统要求
    </h2>
    <ul>
	  <li>与 Python 3.5、3.6、3.7、3.8 和 3.9 兼容</li>
	  <li>如果您在 Linux 上编写 Python 代码，请查看 <a href="https://docs.aspose.com/slides/python-net/system-requirements/">Linux 的附加要求</a></li>
    </ul>
   </div>
   <div class="col-lg-12">
    <h2 class="h2title">
     如何安装
    </h2>
    <p>使用 <strong>pip</strong> 从 <a href="https://pypi.org/project/aspose.slides/">PyPI 存储库</a> 安装我们的 Python 库以进行演示处理</p>:
	<pre><code>pip install aspose.slides</code></pre>
   </div>
    <div class="col-lg-12">
        <h2 class="h2title">创建新的 PowerPoint 演示文稿。 Python PPTX、PPT 或 ODP</h2>
        <p>在下面给出的示例中，我们在演示文稿的第一张幻灯片中添加了一行。</p>
        <pre>
            <code class="python">
import aspose.slides as slides

# Instantiate a Presentation object that represents a presentation file
with slides.Presentation() as presentation:
    slide = presentation.slides[0]
    slide.shapes.add_auto_shape(slides.ShapeType.LINE, 50, 150, 300, 0)
    presentation.save("NewPresentation_out.pptx", slides.export.SaveFormat.PPTX)
            </code>
        </pre>
    </div>
    <div class="col-lg-12">
        <h2 class="h2title">合并演示文稿：Python PPTX、PPT 或 ODP</h2>
        <p>此 Python 代码向您展示了如何合并演示文稿：</p>
        <pre>
            <code class="python">
import aspose.slides as slides

with slides.Presentation("Presentation1.pptx") as pres1:
    with slides.Presentation("Presentation2.pptx") as pres2:
        for slide in pres2.slides:
            pres1.slides.add_clone(slide)
        pres1.save("combined.pptx", slides.export.SaveFormat.PPTX)
            </code>
        </pre>
    </div>
    <div class="col-lg-12">
        <h2 class="h2title"> 从 PDF 导入演示文稿：Python PPTX、PPT 或 ODP</h2>
        <p>此 Python 代码演示了 PDF 到 PowerPoint 的转换过程：</p>
        <pre>
            <code class="python">
import aspose.slides as slides

with slides.Presentation() as pres:
    pres.slides.remove_at(0)
    pres.slides.add_from_pdf("welcome-to-powerpoint.pdf")
    pres.save("OutputPresentation.pptx", slides.export.SaveFormat.PPTX)
            </code>
        </pre>
    </div>
    <div class="col-lg-12">
        <h2 class="h2title">使用默认选项将 PowerPoint 转换为 PDF：Python PPTX、PPT 或 ODP 到 PDF</h2>
        <p>此 Python 代码向您展示如何使用默认选项将 PowerPoint PPT、PPTX 和 OpenOffice ODP 文档转换为 PDF 文档。生成的文件是最高质量级别的 PDF 文档</p>
        <pre>
            <code class="python">
import aspose.slides as slides

# Instantiate a Presentation object that represents a PPT file
presentation = slides.Presentation("PowerPoint.ppt")

# Save the presentation as PDF
presentation.save("PPT-to-PDF.pdf", slides.export.SaveFormat.PDF)
            </code>
        </pre>
    </div>
    <div class="col-lg-12">
        <h2 class="h2title">将 PowerPoint 转换为 JPG：Python PPTX、PPT 或 ODP 转换为 JPEG</h2>
        <p>以下示例向您展示如何将 PowerPoint PPT、PPTX 和 OpenOffice ODP 文档转换为一组 JPEG 图像。</p>
        <pre>
            <code class="python">
import aspose.slides as slides
import aspose.pydrawing as drawing

pres = slides.Presentation("pres.pptx")

for sld in pres.slides:
    bmp = sld.get_thumbnail(1, 1)
    bmp.save("Slide_{num}.jpg".format(num=str(sld.slide_number)), drawing.imaging.ImageFormat.jpeg)
            </code>
        </pre>
    </div>
  </div>
 </div>
</div>

> 我们发现 Aspose.Slides 易于使用并且在我们的服务器上运行良好。我们发现它们满足了动态生成文件的重要需求，以将我们的范围扩展到传统的 Web 应用程序之外。
>
> — Rick Joi | Workplace Dynamics, UK

> 该产品按广告宣传，文档易于理解，支持论坛是我们需要的所有帮助。我们部署的最终解决方案大大超出了我们最初的预期。
>
> — Bruce Brien | Stratascope Inc, USA
