题解 | #配置文件恢复#

配置文件恢复

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

import sys
import re
getline=lambda:sys.stdin.readline().strip()
line=getline()
d={'reset':'reset what','reset board':'board fault','board add':'where to add','board delete':'no board at all','reboot backplane':'impossible','backplane abort':'install first'}
while line:
    if len(line.split(" ")) == 1:
        n=0
        for k in d.keys():
            if re.match("^%s.*"%line, k):
                if (len(k.split(' ')))==1:
                    print(d[k])
                    n=n+1
        if n==0:
            print("unknown command")
    else:
        n=0
        for k in d.keys():
            if re.match("^%s.*%s.*"%(line.split(" ")[0],line.split(" ")[1]), k):
                if (len(k.split(' ')))==2:
                    print(d[k])
                    n=n+1
        if n==0:
            print("unknown command")


    line=getline()
全部评论

相关推荐

点赞 评论 收藏
分享
06-07 19:59
门头沟学院 C++
补药卡我啊😭:都快15年前的了还在11新特性
你的简历改到第几版了
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务