os.system'antiword'+ filepath +'>'+'res.txt'保存空白文本文件

问题描述

我正在尝试使用python从.doc文件中提取文本。 我看到过类似的帖子here,但未能给出预期的结果。

我正在使用一个名为antiword的命令行实用工具和python。当我将其与cmd一起使用时,它可以将文本完美地保存到目标文件中,但使用python失败。

def get_doc_text(self,filepath,file):
    if file.endswith('.docx'):
       text = docx2txt.process(file)
       return text
    elif file.endswith('.doc'):
       doc_file = path.join(filepath,file)
       os.system('antiword ' + doc_file + ' > ' + "C:\\res.txt")  # it should write into res.txt but it's empty.
        

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)