我为此使用catdoc或反字词,无论给出的结果是最容易解析的。我已经将其嵌入到python函数中,因此在解析系统(以python编写)中易于使用。
import osdef 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)# similar doc_to_text_antiword()
-w切换到catdoc会关闭换行,BTW。