无法通过pythons识别参数“outdir”subprocess.call但在泰姆工作吗

2024-05-23 13:47:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我想编写一个python脚本来自动将libreoffice ott模板转换为普通odt文件。 如果我转到终端(bash shell)并键入:

soffice --headless --convert-to odt "/path/template.ott" --outdir '/targetpath/template.odt'

输出如预期,在新的目标位置有一个odt文件。在

当我编写脚本时(如:

^{pr2}$

输出结果显示

[Errno 2] No such file or directory

当我这样打电话时:

subprocess.call(["soffice", "--headless", "--convert-to", "odt", pipes.quote(oldpath),outdir])

结果是soffice的帮助文本,原因是:

    LibreOffice 4.2.8.2 420m0(Build:2)

    Unknown option: --outdir /targetpath/template.odt
...

Tags: 文件to脚本bash模板终端convertlibreoffice