0
点赞
收藏
分享

微信扫一扫

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

依赖包:

from docx import Document
from docx.shared import Pt
from docx.shared import Inches
from docx.oxml.ns import

 

修改正文的中文字体类型,示例代码:(全局设置)

Document()
document.styles['Normal'].font.name=u'微软雅黑'
document.styles['Normal']._element.rPr.rFonts.set(qn('w:eastAsia'), u'微软雅黑')

 

修改3级标题的字体类型,示例代码:

'',level=3).add_run(u"应用场景示例: ")#应用场景示例标题
run.font.name=u'微软雅黑'
run._element.rPr.rFonts.set(qn('w:eastAsia'), u'微软雅黑')

 



举报

相关推荐

0 条评论