标签:年龄 text add ble 支持 docx table document 赋值
from docx import Document w=Document(r‘F:\word练习\a.docx‘) t=[ [‘姓名‘,‘性别‘,‘年龄‘], [‘张三‘,‘男‘,23], [‘李四‘,‘女‘,45], [‘王五‘,‘男‘,60] ] r=4;c=3 table=w.add_table(rows=r,cols=c) #先说明添加的表有几行几列 for row in range(r): cell=table.rows[row].cells for col in range(3): cell[col].text=str(t[row][col]) #指支持字符串的赋值 w.save(r‘F:\word练习\表格.docx‘)
标签:年龄 text add ble 支持 docx table document 赋值
原文地址:https://www.cnblogs.com/luckiness/p/13229371.html