三个目录里的同名命令

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

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

def first_hit(dirs, want, table, ok=None):
    """一串目录从左到右找 want;ok 决定「怎样才算命中」"""
    for d in dirs:
        entry = table.get((d, want))
        if entry is None:
            continue
        if ok is None or ok(entry):
            return d
    return ""
TOOLS = {
    ("a", "tool"): {"能跑": False, "回答": "A"},
    ("b", "tool"): {"能跑": True,  "回答": "B"},
    ("c", "tool"): {"能跑": True,  "回答": "C"},
}
ABC = ["a", "b", "c"]

d = first_hit(ABC, "tool", TOOLS, lambda e: e["能跑"])
print(d + "/" + TOOLS[(d, "tool")]["回答"] + "/" + str(len(ABC)))
提交你的答案
请登录后提交答案。
去登录
代码编辑器
Ctrl + Enter 运行
本次输入:
输出:

                        
👩‍🏫
AI
💬 题目评论

全部评论