宿迁市建设局网站维修基金网站 逻辑结构
风格,页眉和页脚等内容与主要分开,允许在起始文档中放大量自定义,然后在生成文档中显示.
打开文档
from docx import Document
document = Document()
document.save("test.docx")
 
真正打开文档
要用文件名打开文档:
document = Document("existing-document-file.docx")
document.save("new-file-name.docx")
 
打开"类似文件"文档
f = open("foobar.docx", "rb")
document = Document(f)
f.close()
//或
with open("foobar.docx", "rb") as f:source_stream = StringIO(f.read())
document = Document(source_stream)
source_stream.close()
...
target_stream = StringIO()
document.save(target_stream)
