烦!!! 发表于 2020-8-24 14:19:51

列表索引超出范围

from docx import Document
from docx.shared import Cm

file = Document('练习4.docx')

run = file.tables.cell(0,0).paragraphs.add_run()
run.add_picture('图片.jpg',width=Cm(7),height=Cm(7))

file.save('练习5.docx')

报错:Traceback (most recent call last):
File "C:\Users\Administrator\Word自动化\图片.py", line 5, in <module>
    run = file.tables.cell(0,0).paragraphs.add_run()# 查看,设置单元格
IndexError: list index out of range

烦!!! 发表于 2020-8-24 14:48:41

这个问题已经解决了{:10_245:}
页: [1]
查看完整版本: 列表索引超出范围