用Python读取docx文件

-1 投票
1 回答
671 浏览
提问于 2025-04-18 05:52

我找不到任何关于如何用Python读取docx文件的文档。有没有人能提供一个例子呢?

path = 'C:\'
fn = 'file.docx'

1 个回答

1

试试这个链接:

http://www.darkcoding.net/software/printing-word-and-pdf-files-from-python/

from win32com import client
    import time

    word = client.Dispatch("Word.Application")

    def printWordDocument(filename):

        word.Documents.Open(filename)
        word.ActiveDocument.PrintOut()
        time.sleep(2)
        word.ActiveDocument.Close()

    word.Quit()

撰写回答