I want to read header text from a docx file in Python. I am using python-docx module.
Can someone help me to do this, if this feature has already been implemented.
I tried to do this this way, but didn't get a success.
from docx import Document
document = Document(path)
section = document.sections[0]
print(section.text)
Error:
<class 'AttributeError'>'Section' object has no attribute 'text'
And:
from docx import Document
document = Document(path)
header = document.sections[0].header
print(header.text)
Error:
<class 'AttributeError'>'Section' object has no attribute 'header'