python& MS Word:将.doc转换成.docx吗? [英] Python & MS Word: Convert .doc to .docx?

查看:433
本文介绍了python& MS Word:将.doc转换成.docx吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了几个与我的问题类似的问题,但是没有一个答案与我的需要相符.

I found several questions that were similar to mine, but none of the answers came close to what I need.

规格:我正在使用Python 3,并且没有MS Word.我的编程机正在运行OS X,而云机也是linux/ubuntu.

Specifications: I'm working with Python 3 and do not have MS Word. My programming machine is running OS X and cloud machine is linux/ubuntu too.

我正在使用python-docx从每晚发送给我的.doc文件中提取值.但是,python-docx仅适用于.docx文件,因此我需要先将文件转换为该扩展名.

I'm using python-docx to extract values from a .doc file that is sent to me nightly. However, python-docx only works with .docx files, so I need to convert the file to that extension first.

因此,我有一个需要转换为.docx.doc文件.该脚本可能必须在云中运行,因此我无法安装任何种类的Office或类似Office的软件.能做到吗?

So, I've got a .doc file that I need to convert to .docx. This script might have to run in the cloud so I can't install any kind of Office or Office-like software. Can this be done?

推荐答案

您可以使用 unoconv -通用Office转换器.在LibreOffice/OpenOffice支持的任何文档格式之间进行转换.

You could use unoconv - Universal Office Converter. Convert between any document format supported by LibreOffice/OpenOffice.

unoconv -d document --format=docx *.doc

subprocess.call(['unoconv', '-d', 'document', '--format=docx', filename])

这篇关于python& MS Word:将.doc转换成.docx吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆