【问题标题】:how to convert docx file into rtf file using python Is there is any module to do this?如何使用 python 将 docx 文件转换为 rtf 文件是否有任何模块可以做到这一点?
【发布时间】:2021-08-23 08:16:04
【问题描述】:

大家好,我正在尝试使用 python 将 docx 文件转换为 rtf 文件我已经做了很多谷歌搜索,但找不到任何我想要的答案

input = test.docx
output = test.rtf 

【问题讨论】:

标签: python


【解决方案1】:

您可以使用docx 模块并使用此指令安装docx 模块:pip install python-docx。检查代码。

from docx import Document

f = open('test.docx', 'rb')
document = Document(f)

document.save('test.rtf')

【讨论】:

    【解决方案2】:

    https://pypi.org/project/pyandoc/ 这可能会有所帮助

    让我们从一个 Markdown 文档开始:

    doc = pandoc.Document()
    doc.markdown = '''
    # I am an H1 Tag
    
    * bullet point
    * more points
    * point with [link](http://kennethreitz.com)!
    

    现在让我们将其转换为 ReST 文档:

    >>> print doc.rst
    
    I am an H1 Tag
    ==============
    
    
    -  bullet point
    -  more points
    -  point with `link <http://kennethreitz.com>`_!
    

    编辑:阅读文档

    【讨论】:

    • 我用过这个模块,但是它给 pandoc 的属性没有 Document
    猜你喜欢
    • 1970-01-01
    • 2017-04-30
    • 1970-01-01
    • 2021-04-19
    • 2010-12-23
    • 2016-05-23
    • 2019-03-14
    • 2020-10-11
    • 1970-01-01
    相关资源
    最近更新 更多