【问题标题】:How can I use the "pipe" in the python call() function? [duplicate]如何在 python call() 函数中使用“管道”? [复制]
【发布时间】:2016-05-25 03:48:03
【问题描述】:

我正在尝试在 python 中使用 call 方法,如何在(l | grep c++) 中使用管道?

【问题讨论】:

  • call 中的subprocess?可以发一些代码吗?
  • 二进制l是什么?
  • @cricket_007 ls -al的常用bash别名
  • #!usr/bin/env python from subprocess import call call(["ls"])

标签: python python-3.x


【解决方案1】:

基于Python subprocess command with pipe

s = subprocess.Popen(["l"], stdout=subprocess.PIPE)
output = subprocess.check_output(("grep", "c++"), stdin=s.stdout)

【讨论】:

    猜你喜欢
    • 2017-05-06
    • 2011-03-22
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    • 2019-09-21
    • 2019-02-16
    • 1970-01-01
    • 2020-04-27
    相关资源
    最近更新 更多