我想在linux上使用Python打开一个ppt文件(就像python打开一个.txt文件)。
我知道win32com,但我正在linux上工作。
那么,我需要做什么?
python-pptx https://python-pptx.readthedocs.org可以在 Linux 上打开最新的 Powerpoint 版本。他们甚至提供了一个例子从幻灯片中提取所有文本 https://python-pptx.readthedocs.org/en/latest/user/quickstart.html#extract-all-text-from-slides-in-presentation在他们的入门 https://python-pptx.readthedocs.org/en/latest/user/quickstart.html guide.
这是代码(来自入门 https://python-pptx.readthedocs.org/en/latest/user/quickstart.html guide)
from pptx import Presentation
prs = Presentation(path_to_presentation)
# text_runs will be populated with a list of strings,
# one for each text run in presentation
text_runs = []
for slide in prs.slides:
for shape in slide.shapes:
if not shape.has_textframe:
continue
for paragraph in shape.textframe.paragraphs:
for run in paragraph.runs:
text_runs.append(run.text)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)