照着跑,能走到第几步

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

四步说明,仓库里缺一个文件。运行下面这段程序,看成功跑过几步、卡在第几步:

def dry_run(steps, files):
    for i, (cmd, need) in enumerate(steps, 1):
        if need and need not in files:
            return i, need
    return 0, None

steps = [('git clone https://example.com/calc.git', None),
         ('cd calc', None),
         ('pip install -r requirements.txt', 'requirements.txt'),
         ('python main.py', 'main.py')]
files = ['main.py', 'calc.py', 'README.md']
i, _ = dry_run(steps, files)
print(str(i - 1) + "/" + str(i))
提交你的答案
请登录后提交答案。
去登录
代码编辑器
Ctrl + Enter 运行
本次输入:
输出:

                        
👩‍🏫
AI
💬 题目评论

全部评论