子流程检查当前目录下的输出/运行问题

2024-10-02 20:39:04 发布

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

当从命令行运行此命令时,它会起作用

plutil -convert xml1 test.out -o outFile1.xml

在python 2.7中运行此命令时,我得到一个错误:

import subprocess
subprocess.check_output(["plutil -convert xml1 test.out -o outFile1.xml"])
OSError: [Errno 2] No such file or directory

我尝试将./.\\添加到目录中

我使用了pwdos.getcwd()来确保在这两种情况下我都是从同一个目录运行这个程序的


Tags: 命令行testimport命令目录convertoutputcheck
1条回答
网友
1楼 · 发布于 2024-10-02 20:39:04

把你的指挥权分开应该行得通;口译员目前可能对它感到困惑

subprocess.check_output(["/usr/bin/plutil", "-convert", "xml1", "test", "-o", "outFile1.xml"])

此外,您可能希望使用plutil的绝对路径(可选)

相关问题 更多 >