【问题标题】:What's the meaning of "git", "remote","-v" with subprocess.check_output?subprocess.check_output中的“git”,“remote”,“-v”是什么意思?
【发布时间】:2019-01-02 11:37:55
【问题描述】:

我完全不明白以下代码行的含义。

我发现subprocess.check_outputpython 2.7 中给出了一个字节串,但是这里的["git", "remote","-v"] 是什么意思呢? stderr=subprocess.STDOUT 有什么用?谢谢。

out = subprocess.check_output(["git", "remote","-v"]), stderr=subprocess.STDOUT)

【问题讨论】:

    标签: python python-2.7 subprocess


    【解决方案1】:

    此命令检查 shell 命令git remote -v 的输出,并将其错误通过管道传输到标准输出。这实际上很不寻常,通常人们使用subprocess.PIPE,这样他们就可以在任何他们想要的地方传递错误。但在这种情况下,您将在 out.stdout 中访问该命令的输出。

    【讨论】:

      【解决方案2】:

      subprocess.check_output 给出 shell 命令的输出 作为字节字符串。 git 是一个版本控制工具,要查看命令的确切作用,您可以阅读 git 文档或例如使用explain shellgit remote 显示现有远程存储库的列表,-v 将 repo url 添加到输出中)。

      【讨论】:

        猜你喜欢
        • 2022-01-22
        • 1970-01-01
        • 1970-01-01
        • 2015-04-30
        • 2015-10-06
        • 2023-01-19
        • 2012-03-03
        • 1970-01-01
        相关资源
        最近更新 更多