美文网首页
python-docx

python-docx

作者: 兔子不会武 | 来源:发表于2019-11-21 11:38 被阅读0次
from docx import Document
from docx.shared import Pt
from docx.shared import Inches
from docx.oxml.ns import qn

# 修改正文的中文字体类型,示例代码:(全局设置)
document=Document()
document.styles['Normal'].font.name=u'微软雅黑'
document.styles['Normal']._element.rPr.rFonts.set(qn('w:eastAsia'), u'微软雅黑')

# 修改3级标题的字体类型,示例代码:
run = document.add_heading('',level=3).add_run(u"应用场景示例: ")#应用场景示例标题
run.font.name=u'微软雅黑'
run._element.rPr.rFonts.set(qn('w:eastAsia'), u'微软雅黑') 

python-docx 设置标题heading的中文字体类型+设置正文的中文字体类型

相关文章

网友评论

      本文标题:python-docx

      本文链接:https://www.haomeiwen.com/subject/xggzictx.html