我使用pythondocx和django来生成word文档。在
有没有一种方法可以使用add_picture
从web而不是从文件系统添加图像?在
在word中,当我选择添加图片时,我可以只给出URL。 我试着同样的方式写下:
document.add_picture("http://icdn4.digitaltrends.com/image/microsoft_xp_bliss_desktop_image-650x0.jpg")
得到了错误:
IOError: [Errno 22] invalid mode ('rb') or filename: 'http://icdn4.digitaltrends.com/image/microsoft_xp_bliss_desktop_image-650x0.jpg'
如果使用
docxtemplater
(命令行界面)您可以创建自己的模板,并使用URL嵌入图像。在
参见:https://github.com/edi9999/docxtemplater
docxtemplater command line interface
docxtemplater image replacing
下面是Python 3的新实现:
不是很优雅,但我根据here中的问题找到了一个解决方案
我的代码现在是这样的:
这个很好用。在
相关问题 更多 >
编程相关推荐