swanseabrian 发表于 2022-2-8 20:01:30

Python-docx插入图片可以不自动换行吗

在一行插入两张图片

请问在一行里可以插入两张图片吗

import os
from docx import Document
from docx.shared import Cm
file = Document(input('word文档位置:'))
a=1
for i,j,filename in os.walk(input('请输入文档目录:')+'/'):
    print(i,j,filename)
    if len(filename)>=2:
      name = i[-3:]
      if name=='/':
            name=name[-2:]
      file.add_paragraph('%s.%s' % (a, name))
      a += 1
      for k in filename:
            file.add_picture('%s/%s' % (i, k), width=Cm(5), height=Cm(13))

file.save('C:/test.docx')

阿灿01 发表于 2022-12-5 10:37:43

python docx 方法还不完全,不过这个功能可以通过表格插入图片的操作实现

然而,我不能给你贴链接{:10_266:}
页: [1]
查看完整版本: Python-docx插入图片可以不自动换行吗