我有一些文本存储在.docx
文件:
Dear xx01xx,
Thank you for coming to my birthday party. I’m glad you came. Thanks for the xx02xx present!
Your best friend,
Alan Bagel
If you want to see my token of appreciation for your coming, please go to xx03xx street.
现在当我试着从中读取文本时:
import docx
template = docx.Document("...")
for paragraph in template.paragraphs:
print(paragraph.text)
结果只是一个换行符!对.docx
文件的支持是否如此有限,以至于可以被文件行上较小的字体大小所混淆?
问题是,即使您创建了一个.docx
文件,您忘记保存它,因此python-docx
无法读取它。