import docx
from docx import Document
#导入word文档
doc=Document('word.docx')
#提取文档内容中的标题
for p in doc.paragraphs:
style_name = p.style.name
if style_name.startswith('Heading'):
print(style_name)
为什么可以这么写:style_name = p.style.name
为什么不能这么写:style_name = doc.paragraphs.style.name