管道里前面失败了

👁️ 1 人浏览 💬 0 人评论 ❤️ 添加收藏

运行下面这段程序,填写它打印出来的结果。

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))
提交你的答案
请登录后提交答案。
去登录
代码编辑器
Ctrl + Enter 运行
本次输入:
输出:

                        
👩‍🏫
AI
💬 题目评论

全部评论