用python读取docx文件

时间:2014-05-08 16:37:02

标签: python python-3.x printing ms-word docx

我找不到任何描述如何使用python读取docx文件的文档。有没有人有他们会提供的例子?

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

1 个答案:

答案 0 :(得分: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()
相关问题