python-pptx 在 windows 7 64x 中加载(2003 转换)2010 powerpoint 文档时抛出错误?
python-pptx throwing error on loading (2003 converted) 2010 powerpoint document in windows 7 64x ?
我正在使用 python-pptx 版本 0.5.7 - Windows 7 64x。我不确定如何处理,因为我在网上找到的所有东西都不起作用。我不确定为什么会收到 zip 文件错误,因为这是一个 powerpoint 文档。
一如既往地感谢您的帮助。
>>> from pptx import Presentation
>>> f = open("Randy-Diehl-Analysis.pptx")
>>> prs = Presentation(f)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\pptx\api.py", line 26, in __init__
self._package = Package.open(pkg_file)
File "C:\Python27\lib\site-packages\pptx\package.py", line 44, in open
return super(Package, cls).open(pkg_file)
File "C:\Python27\lib\site-packages\pptx\opc\package.py", line 122, in open
pkg_reader = PackageReader.from_file(pkg_file)
File "C:\Python27\lib\site-packages\pptx\opc\pkgreader.py", line 32, in from_file
phys_reader = PhysPkgReader(pkg_file)
File "C:\Python27\lib\site-packages\pptx\opc\phys_pkg.py", line 102, in __init__
self._zipf = ZipFile(pkg_file, 'r')
File "C:\Python27\lib\zipfile.py", line 712, in __init__
self._GetContents()
File "C:\Python27\lib\zipfile.py", line 746, in _GetContents
self._RealGetContents()
File "C:\Python27\lib\zipfile.py", line 787, in _RealGetContents
centdir = struct.unpack(structCentralDir, centdir)
struct.error: unpack requires a string argument of length 46
我需要指定 读取和写入 参数才能使用该文件。
f = open("Randy-Diehl-Analysis.pptx", "r+b")
我正在使用 python-pptx 版本 0.5.7 - Windows 7 64x。我不确定如何处理,因为我在网上找到的所有东西都不起作用。我不确定为什么会收到 zip 文件错误,因为这是一个 powerpoint 文档。
一如既往地感谢您的帮助。
>>> from pptx import Presentation
>>> f = open("Randy-Diehl-Analysis.pptx")
>>> prs = Presentation(f)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\pptx\api.py", line 26, in __init__
self._package = Package.open(pkg_file)
File "C:\Python27\lib\site-packages\pptx\package.py", line 44, in open
return super(Package, cls).open(pkg_file)
File "C:\Python27\lib\site-packages\pptx\opc\package.py", line 122, in open
pkg_reader = PackageReader.from_file(pkg_file)
File "C:\Python27\lib\site-packages\pptx\opc\pkgreader.py", line 32, in from_file
phys_reader = PhysPkgReader(pkg_file)
File "C:\Python27\lib\site-packages\pptx\opc\phys_pkg.py", line 102, in __init__
self._zipf = ZipFile(pkg_file, 'r')
File "C:\Python27\lib\zipfile.py", line 712, in __init__
self._GetContents()
File "C:\Python27\lib\zipfile.py", line 746, in _GetContents
self._RealGetContents()
File "C:\Python27\lib\zipfile.py", line 787, in _RealGetContents
centdir = struct.unpack(structCentralDir, centdir)
struct.error: unpack requires a string argument of length 46
我需要指定 读取和写入 参数才能使用该文件。
f = open("Randy-Diehl-Analysis.pptx", "r+b")