我在寻找一种方法来删除标准输出由脚本生成的输出的一部分。我们假设输出如下: line 1: some text...
line 2: other text...
line 3: and so on...
此时脚本我称之为os.system("ls")的,这产生在当前目录中的文件与我不能预先知道的输出量清单。因此,标准输出将更新为 line 1: some text...
line 2:
我试图通过行改为子行: proc = subprocess.Popen(self.monitor_logcat_cmd, shell=True, stdout=subprocess.PIPE,
bufsize=1, universal_newlines=True)
while proc.poll() is None:
line = proc.stdout.read