中被称为inside add_run
def add_run(self, text=None, style=None):
r = self._p.**add_r()**
run = Run(r, self)
if text:
run.text = text
if style:
run.style = style
return run发布于 2020-07-22 05:35:00
为了响应类定义中的声明,它通过其元类将其添加到docx.oxml.text.paragraph.CT_P类:
class CT_P(BaseOxmlElement):
"""
``<w:p>`` element, containing the properties and text for a paragraph.
"""
pPr = ZeroOrOne('w:pPr')
r = ZeroOrMore('w:r') # <--- this line causes the metaclass to create the .add_r() methodhttps://github.com/python-openxml/python-docx/blob/master/docx/oxml/text/paragraph.py#L16
https://stackoverflow.com/questions/62967700
复制相似问题