Google drive api Pydrive docx文件上载未还原书签链接
我有一个python脚本,它使用pythondocx创建docx文件。文档文件的超链接设置为链接在文档段落内的书签。如果我在笔记本电脑中打开文档,它会正确显示。但当我上传后在谷歌硬盘上打开文档时,它跳过了超链接部分。你知道哪里出了问题吗?这就是我使用pydrive上传文档的方式。如果有帮助的话,我应该尝试以PDF格式上传吗Google drive api Pydrive docx文件上载未还原书签链接,google-drive-api,python-docx,pydrive,Google Drive Api,Python Docx,Pydrive,我有一个python脚本,它使用pythondocx创建docx文件。文档文件的超链接设置为链接在文档段落内的书签。如果我在笔记本电脑中打开文档,它会正确显示。但当我上传后在谷歌硬盘上打开文档时,它跳过了超链接部分。你知道哪里出了问题吗?这就是我使用pydrive上传文档的方式。如果有帮助的话,我应该尝试以PDF格式上传吗 http = drive.auth.Get_Http_Object() # createfile file1 = drive.CreateFile(
http = drive.auth.Get_Http_Object()
# createfile
file1 = drive.CreateFile({'title': 'Test Report.docx',
'mimeType': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'})
file1.SetContentFile("read.docx")
file1.Upload(param={"http": http})
找到了无需打开word文档即可执行此操作的正确方法。它需要安装PyWin32 lib
import win32com.client
def update_toc(file):
word = win32com.client.DispatchEx("Word.Application")
print(os.path.join(os.getcwd(), file))
doc = word.Documents.Open(os.path.join(os.getcwd(), file))
doc.TablesOfContents(1).Update()
word.ActiveDocument.Fields.Update()
doc.Close(SaveChanges=True)
word.Application.Quit()
您使用什么代码创建超链接?此链接上有一个线程: