我想将所有 .doc 文件从特定文件夹转换为 .docx 文件。
我尝试使用以下代码,
import subprocess
import os
for filename in os.listdir(os.getcwd()):
if filename.endswith('.doc'):
print filename
subprocess.call(['soffice', '--headless', '--convert-to', 'docx', filename])
但它给了我一个错误:OSError: [Errno 2] No such file or directory
原文由 sunil pawar 发布,翻译遵循 CC BY-SA 4.0 许可协议
这是一个对我有用的解决方案。提出的其他解决方案在我使用 Python 3 的 Windows 10 机器上不起作用。