import subprocess
subprocess.check_output(
[“soffice”, “–headless”, “–invisible”, “–convert-to”, “docx”, file_path, “–outdir”,
‘’.join(file_path.split(’.’)[:-1])])
如果没有 soffice 命令,执行安装
apt update
apt install libreoffice
转换成docx
import subprocess
subprocess.check_output(
[“soffice”, “–headless”, “–invisible”, “–convert-to”, “docx”, file_path, “–outdir”,
‘’.join(file_path.split(’.’)[:-1])])
如果没有 soffice 命令,执行安装
apt update
apt install libreoffice
转换成docx