【发布时间】:2016-10-09 20:05:19
【问题描述】:
我正在尝试读取 docx 文件的 last_saved_by 属性。我在 Github 和 this question 上关注了 cmets。似乎已经添加了支持,但是文档对我来说不是很清楚。
我已在我的脚本 (Notepad++) 中输入了以下代码:
import docx
document = Document()
core_properties = document.core_properties
core_properties.author = 'Foo B. Baz'
document.save('new-filename.docx')
最后我只收到一条错误消息:
NameError: name 'Document' is not defined
我不确定我哪里出错了。 :(
当我通过python本身逐行输入时,问题似乎来自第二行。
我使用的是 Python 3.4 和 docx 0.8.6
【问题讨论】:
-
我猜是
docx.Document或docx.something.Document而不仅仅是Document
标签: python python-3.x word-2010 python-docx