管道里前面失败了
运行下面这段程序,填写它打印出来的结果。
def run(steps, stop_on_error=False):
"""steps 是一串退出码;返回 (跑了几条, 整个脚本的退出码)"""
ran = 0
last = 0
for rc in steps:
ran = ran + 1
last = rc
if stop_on_error and rc != 0:
return ran, rc
return ran, last
def ok(rc):
return rc == 0
pipe = [1, 0]
without = pipe[-1]
with_pipefail = 0
for rc in pipe:
if rc != 0:
with_pipefail = rc
print(str(without) + "/" + str(with_pipefail))
全部评论