准备
需要安装libreoffice这个软件
下载地址:https://www.libreoffice.org/download/download/
代码
import os import subprocess source = "doc文件夹路径" dest = "要转换的docx文件夹路径"# 提前建好 app_path = "/Applications/LibreOffice.app/Contents/MacOS/soffice"# LibreOffice的安装路径 g = os.listdir(source) file_path = [f for f in g if f.endswith(('.doc'))] print(file_path) for i in file_path: file = (source + '/' + i) print(file) output = subprocess.check_output([ app_path, "--headless", "--convert-to", "docx", file, "--outdir", dest]) print('success!')
标签:docx,python,doc,app,source,file,path From: https://www.cnblogs.com/bubblebeee/p/17096397.html