Python 3.3
docx 7.6
from docx import Document with open('demo.docx') as f: document = Document(f)
Выдает примерно следующее:
Traceback (most recent call last):
File “C
Users/A7/PycharmProjects/documentsproject/testforopen.py”, line 4, in <module>document = Document(f)
File “C:\Python33\lib\site-packages\python_docx-0.7.6-py3.3.egg\docx\api.py”, line 35, in __init__
document_part, package = self._open(docx)
File “C:\Python33\lib\site-packages\python_docx-0.7.6-py3.3.egg\docx\api.py”, line 193, in _open
package = Package.open(docx)
File “C:\Python33\lib\site-packages\python_docx-0.7.6-py3.3.egg\docx\opc\package.py”, line 116, in open
pkg_reader = PackageReader.from_file(pkg_file)
File “C:\Python33\lib\site-packages\python_docx-0.7.6-py3.3.egg\docx\opc\pkgreader.py”, line 32, in from_file
phys_reader = PhysPkgReader(pkg_file)
File “C:\Python33\lib\site-packages\python_docx-0.7.6-py3.3.egg\docx\opc\phys_pkg.py”, line 101, in __init__
self._zipf = ZipFile(pkg_file, ‘r’)
File “C:\Python33\lib\zipfile.py”, line 935, in __init__
self._RealGetContents()
File “C:\Python33\lib\zipfile.py”, line 976, in _RealGetContents
raise BadZipFile(“File is not a zip file”)
zipfile.BadZipFile: File is not a zip file
Как быть? Или чем другим поработать с файлами? Или придется изобретать велосипед и учиться парсить xml файлы?
Спасибо за внимание!