首页 > 解决方案 > 无法使用 docx 正确放置我的图像

问题描述

这是我的代码:

from docx import Document
from docx.shared import Inches
from datetime import date
import excel2img

excel2img.export_img("test.xlsx","image2.png",  "Sheet1", "G13:J22")


document = Document('filename.docx')

paragraphs = document.paragraphs


paragraph = paragraphs[0]

run = paragraph.add_run()
run.add_picture('image2.png', width=Inches(6.65), height=Inches(2.02))

document.save('new.docx')

这是我的单词输出:

输出字

问题是:如何将图像放在粗体文本上方?我不能输入小于 0paragraph = paragraphs[0]

标签: python-3.xdocxpython-docx

解决方案


推荐阅读