西安做网站公司必达/百度关键词多少钱一个月
需求:
之前学会了简单的设置行run的样式,现在有些更高要求,需要对段落设置样式,这里就用到了docx包。
1. 缩进(首行缩进,左/右缩进)
2. 对齐
3. 间距
4. 在word中指定格式,不需程序专门设定
实现一:缩进
缩进包括:首行缩进(first_line_indent),左/右缩进(left_indent/right_indent)
缩进的时候需要设置单位,Pt Cm Inches
from docx.shared import Pt, Cm, Inches
A 首行缩进
1. 模板
{{p mytest }}
2. 代码
\n换行可以识别
from docxtpl import DocxTemplate
from docx import *
from docx.shared import Cmdef