【问题标题】:Accept track changes and convert .doc to .txt using CATDOC接受跟踪更改并使用 CATDOC 将 .doc 转换为 .txt
【发布时间】:2015-03-13 11:50:59
【问题描述】:

如何在使用 catdoc 将 .doc 文件转换为 .txt 文件时接受音轨更改?

假设有两个文件'original.doc'和'modified.doc'。

'original.doc'有以下句子:this a test sentence 'modified.doc' 有以下句子:this is a test statement

当我将 modified.doc 转换为 .txt 文件而不是得到 this is a test statement 时,我得到的是 this is a test sentence statement

我正在使用下面的代码。

def doc_to_text_catdoc(filename):
(fi, fo, fe) = os.popen3('catdoc -w "%s"' % filename)
fi.close()
retval = fo.read()
erroroutput = fe.read()
fo.close()
fe.close()
if not erroroutput:
    return retval
else:
    raise OSError("Executing the command caused an error: %s" % erroroutput)

【问题讨论】:

    标签: python text doc


    【解决方案1】:

    使用 Antiword 解决了问题。

    (fi, fo, fe) = os.popen3('antiword -f "%s"' % filename)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-06
      • 2014-01-26
      • 2015-06-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多