https://blog.csdn.net/hwwaizs/article/details/121186150
https://www.e-iceblue.cn/Introduce/Spire-Doc-Python.html
https://www.e-iceblue.cn/doc_python_textbox/python-add-or-remove-textboxes-in-a-word-document.html
pip install python-docx
from docx import Document
doc = Document() # 创建一个新的文档对象
doc.add_paragraph('Hello, world!') # 添加一个段落
doc.save('hello_world.docx') # 保存文档
doc = Document('existing_doc.docx') # 打开一个现有文档
doc.add_paragraph('This is a new paragraph.') # 在文档末尾添加一个新段落
doc.save('existing_doc.docx') # 保存文档
doc = Document('example.docx')
for para in doc.paragraphs:
print(para.text)
#全局
doc = docx.Document()
doc.styles['Normal'].font.name = '宋体'
doc.styles['Normal']._element.rPr.rFonts.set(qn('w:eastAsia'), '宋体')
# 段落设置
p1 = doc.add_paragraph()
run = p1.add_run('这里是测试文字')
run.font.name = '黑体'
run.element.rPr.rFonts.set(qn('w:eastAsia'), '黑体')