我正在提取文件中以“abc”开头的第一行
grep -w 'abc' --max-count=1 file.tsv
我想在 python 程序中使用它
import subprocess
process = subprocess.Popen("grep -w 'abc' --max-count=1 file.tsv",
shell=True,
stdout=subprocess.PIPE,
)
stdout = process.communicate()[0].split('\n')
我的 python 正在运行Windows
并且grep
无法工作。有没有可以在我的 python 程序中使用的替代方法。