python-pptx - 如何使用 Python 将 PPT 文件保存为 PPTX 文件?或如何使用 python-pptx 准备 PPT 文件?
问题描述
我试过下面的代码,但我无法将PPT文件保存为PPTX文件。
from pptx import Presentation
import os
import glob
for each_file in glob.glob("C:/Users/Downloads/*.ppt"):
#prs = Presentation(each_file)
fname=os.path.basename(each_file)
f = open(each_file)
f.save(fname[:-4]+'.pptx')
f.close()```
***Error***: `AttributeError: '_io.TextIOWrapper' object has no attribute 'save'`
解决方案
似乎.ppt
不支持文件。
以下行(.ppt files from PowerPoint 2003 and earlier won’t work)
位于python-pptx
文档的第 13 页:https ://readthedocs.org/projects/python-pptx/downloads/pdf/latest/
推荐阅读
- c# - 为每个用户身份设置会话
- java - 使用 swagger 变形器和 dropwizard 上传文件
- r - Error in installing "TopicModels" package in google collab
- php - 根据 URL 中的变量从数据库中获取数据
- unity3d - 如何通过统一 2d 中的脚本重新启动我当前所在的场景,以便重置我的精灵?
- r - 如何根据其他两个相应列之间的条件匹配在我的数据框中创建一个新列:R
- git - 如何仅修改最后的第二次提交或特定提交
- python - Python:将图像转换为像素列表的反向?
- node.js - 如何在 Typescript + React 中覆盖模块中的类型
- c# - ASP.NET MVC 显示