当我运行代码时,我希望每次将logo文件附加在Word文档中。
理想情况下,代码应该如下所示:
from docx import Document
document = Document()
logo = open('logo.eps', 'r') #the logo path that is to be attached
document.add_heading('Underground Heating Oil Tank Search Report', 0) #simple heading that will come bellow the logo in the header.
document.save('report for xyz.docx') #saving the file
这是否在python-docx中可行,或者我应该尝试其他库来完成这个任务?如果可能,请告诉我如何做。