python使用管道获取其它进程的输出内容

来源:互联网 发布:国际编程证书 编辑:程序博客网 时间:2024/05/23 18:34
def GetLineListFromFile(sFileName):sCmd = "grep -i 'iphone os' " + sFileName;output = subprocess.Popen([sCmd],stdout=subprocess.PIPE,shell=True).communicate()lines = output[0].split('\n');return lines;#print (res)def GetLineListFromArch(sFileName):sCmd = "zgrep -i 'iphone os' " + sFileName;output = subprocess.Popen([sCmd],stdout=subprocess.PIPE,shell=True).communicate()lines = output[0].split('\n');return lines;