<分区>
我想做的事情的要点是:
grep -n "some phrase" {some file path} | head -1
我想将其输出传递给 python。到目前为止我尝试过的是:
p = subprocess.Popen('grep -n "some phrase" {some file path} | head -1',shell=True,stdout=subprocess.PIPE)
我收到很多消息说
"grep: writing output: Broken pipe"
我对 subprocess
模块不是很熟悉,我想得到有关如何获得此输出以及我目前做错了什么的建议。