Python:AttributeError:';模块';对象没有属性';WD#u BREAK';

Python:AttributeError:';模块';对象没有属性';WD#u BREAK';,python,docx,attributeerror,Python,Docx,Attributeerror,这是我的密码: import docx doc = docx.Document() doc.add_paragraph('This is on first page!') doc.paragraphs[0].runs[0].add_break(docx.text.WD_BREAK.PAGE) doc.add_paragraph('This is on the second page!') doc.save('twoPage.docx') 错误是: AttributeError: 'modul

这是我的密码:

import docx

doc = docx.Document()
doc.add_paragraph('This is on first page!')
doc.paragraphs[0].runs[0].add_break(docx.text.WD_BREAK.PAGE)
doc.add_paragraph('This is on the second page!')
doc.save('twoPage.docx')
错误是:

AttributeError: 'module' object has no attribute 'WD_BREAK'
包含在
docx.enum.text
中。你应该改变

docx.text.WD_BREAK.PAGE

python3.7

import docx
doc = docx.Document()
doc.add_paragraph('This is on first page!')
doc.paragraphs[0].runs[0].add_break(docx.text.run.WD_BREAK.PAGE)
doc.add_paragraph('This is on the second page!')
doc.save('twoPage.docx')
import docx
from docx.text.run import *
doc = docx.Document()
doc.add_paragraph('This is on first page!')
doc.paragraphs[0].runs[0].add_break(WD_BREAK.PAGE)
doc.add_paragraph('This is on the second page!')
doc.save('twoPage.docx')
import docx
doc = docx.Document()
doc.add_paragraph('This is on first page!')
doc.paragraphs[0].runs[0].add_break(docx.text.run.WD_BREAK.PAGE)
doc.add_paragraph('This is on the second page!')
doc.save('twoPage.docx')