mailmerge: What does 'ValueError: Element is not a child of this node' mean?
mailmerge: What does 'ValueError: Element is not a child of this node' mean?
我正在尝试用 docx-mailmerge 填充 Python 中的 Word 文档。一切正常,但在家中使用另一台 Word 版本的另一台计算机进行一些编辑后,我的脚本在以下行出现错误:
document = MailMerge(template)
错误:
document = MailMerge(template)
File "C:\Python27\lib\site-packages\mailmerge.py", line 79, in __init__
parent.remove(child)
File "src\lxml\lxml.etree.pyx", line 950, in lxml.etree._Element.remove
(src\lxml\lxml.etree.c:50327)
ValueError: Element is not a child of this node.
这是什么意思?
您没有给我们任何 运行 时间上下文,但此消息只是告诉您给定行的对象 lmxl.etree
没有名为 [= 的属性(数据字段) 11=]。 etree
显然存在,但显然不是预期的类型或结构。树节点可能以某种方式未完全形成:电子表格单元格为空,或具有严重无效的值。
我遇到了与 docx-mailmerge 类似的问题。事实证明,在我的 .docx 文件中,单个合并字段上的大括号不在同一行,因此 mailmerge 无法正确检测到合并字段。
示例:{ MERGEFIELD Foo }
固定:{ MERGEFIELD Foo }
我正在尝试用 docx-mailmerge 填充 Python 中的 Word 文档。一切正常,但在家中使用另一台 Word 版本的另一台计算机进行一些编辑后,我的脚本在以下行出现错误:
document = MailMerge(template)
错误:
document = MailMerge(template)
File "C:\Python27\lib\site-packages\mailmerge.py", line 79, in __init__
parent.remove(child)
File "src\lxml\lxml.etree.pyx", line 950, in lxml.etree._Element.remove
(src\lxml\lxml.etree.c:50327)
ValueError: Element is not a child of this node.
这是什么意思?
您没有给我们任何 运行 时间上下文,但此消息只是告诉您给定行的对象 lmxl.etree
没有名为 [= 的属性(数据字段) 11=]。 etree
显然存在,但显然不是预期的类型或结构。树节点可能以某种方式未完全形成:电子表格单元格为空,或具有严重无效的值。
我遇到了与 docx-mailmerge 类似的问题。事实证明,在我的 .docx 文件中,单个合并字段上的大括号不在同一行,因此 mailmerge 无法正确检测到合并字段。
示例:{ MERGEFIELD Foo }
固定:{ MERGEFIELD Foo }