题解 | #配置文件恢复# 反正都双列表了可以更彻底一点

配置文件恢复

https://www.nowcoder.com/practice/ca6ac6ef9538419abf6f883f7d6f6ee5

while True:
    try:
        s = input().split()

        cmd_map = [
            ["reset", "board", "board fault"],
            ["board", "add", "where to add"],
            ["board", "delete", "no board at all"],
            ["reboot", "backplane", "impossible"],
            ["backplane", "abort", "install first"],
        ]

        out = "unknown command"
        if len(s) == 1:
            if "reset".startswith(s[0]):
                out = "reset what"
        elif len(s) == 2:
            flag = 0
            for cmd in cmd_map:
                if cmd[0].startswith(s[0]) and cmd[1].startswith(s[1]):
                    # 匹配到了
                    flag += 1
                    out = cmd[2]
            if flag != 1:
                out = "unknown command"


        print(out)
    except:
        break

全部评论

相关推荐

点赞 评论 收藏
分享
dongsheng66:如果想进大厂的话,在校经历没必要占这么大篇幅,可以把专业技能单独放一个专栏写,可以加个项目经历
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务