AttributeError: 'function' object has no attribute 'add_heading'

Viewed 26

I would like to run the following code in python:

document = Document()
paragraph = Document.add_heading(title, 0)
paragraph.alignment = 1
paragraph = document.add_paragraph('    '  + text)
paragraph = document.add_paragraph(name)
paragraph.alignment = 2
document.save(title + ".docx")

but it returns the following error:

Exception has occurred: AttributeError
'function' object has no attribute 'add_heading'

File "C:\Users\Pichau\Desktop\codigos\genius lamp.py", line 29, in <module>
    paragraph = Document.add_heading(title, 0)
0 Answers
Related