标签: python python-3.x
我试图在python中使用call方法,如何在(l | grep c++)中管道?
(l | grep c++)
答案 0 :(得分:3)
基于Python subprocess command with pipe
s = subprocess.Popen(["l"], stdout=subprocess.PIPE) output = subprocess.check_output(("grep", "c++"), stdin=s.stdout)