超鏈接可以使用win32com包添加:
import win32com.client
#connect to Word (start it if it isn't already running)
wordapp = win32com.client.Dispatch("Word.Application")
#add a new document
doc = wordapp.Documents.Add()
#add some text and turn it into a hyperlink
para = doc.Paragraphs.Add()
para.Range.Text = "Adding hyperlinks in Microsoft word using python"
doc.Hyperlinks.Add(Anchor=para.Range, Address="http://stackoverflow.com/questions/34636391/adding-hyperlinks-in-microsoft-word-using-python")
#In theory you should be able to also pass in a TextToDisplay argument to the above call but I haven't been able to get this to work
#The workaround is to insert the link text into the document first and then convert it into a hyperlink
您可以使用Python,DOCX創建一個從(正確的)XML文檔DOCX。如果您使用超鏈接創建Word文檔,可以將其解壓縮,查看正確的標記,並將其用作模板來操作現有文檔。 – Marcin
在Marcin的評論之上,如果你看看並且在這裏挖掘(https://github.com/python-openxml/python-docx/issues/74),它可能會有所幫助。不知道這是否合併到主。 – disflux