我在使用 Python 中的 libreoffice 时遇到了最令人沮丧的问题
当我在终端中运行以下命令时,我完全没有问题,pdf文件在我想要的地方生成,生活很美好:
cd /Applications/LibreOffice.app/Contents/MacOS/
./soffice --convert-to pdf --outdir {output_folder} {path_to_docx_file}/{title}.docx
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试将其添加到我的 python 脚本中时:
SOFFICE = r'/Applications/LibreOffice.app/Contents/MacOS/soffice'
subprocess.Popen([SOFFICE, "--convert-to", "pdf", "--outdir", "{output_folder} ", "{path_to_docx_file}/{title}.docx"])
Run Code Online (Sandbox Code Playgroud)
我收到一条错误消息:
错误:无法加载源文件
我已经尝试打开所有二进制文件和文件的所有权限,但这在 python 脚本中仍然不起作用。我究竟做错了什么?