问题
From the script here I see how to set document keywords with the coreproperties function of python-docx. I want to look at the keywords already in a document written by someone else. Is there a getcoreproperties function or a keywords attribute or something similar?
I've grepped in folder C:\Python27\Lib\site-packages\python_docx-0.5.0-py2.7.egg\docx and none of the .py files there have the string "core" in them, and I've called doc() on a few things but without finding anything promising. Where/how should I look for clues to this kind of thing?
回答1:
The python-docx
library doesn't have support for core properties as of v0.5.0. But as it happens, that should be relatively easy to remedy.
The python-pptx
sister project has support for core properties, as explained here:
http://python-pptx.readthedocs.org/en/latest/api/presentation.html#coreproperties-objects
Since the two projects are based on the same architecture, that code should be reusable essentially as-is. It turns out the core-properties bits are common to the the Open Packaging Convention, which is the same for all three of the MS Office XML file formats.
If you'll add an issue on the GitHub issue tracker I'll see how soon we can get to it. https://github.com/python-openxml/python-docx/issues
来源:https://stackoverflow.com/questions/22625022/reading-coreproperties-keywords-from-docx-file-with-python-docx