题解 | #配置文件恢复# 细心就好,有少敲键盘的技巧

配置文件恢复

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

import sys
_dic={
'reset board':'board fault',
'board add': 'where to add',
'board delete':'no board at all',
'reboot backplane':'impossible',
'backplane abort':'install first',
'he he':'unknown command'
}

for line in sys.stdin:
    ot='unknown command'
    l=line.strip().split(' ')
    if len(l)==1:
        if l[0] in 'reset':
            ot='reset what'
    elif len(l)==2:
        get=0
        for k in _dic.keys():
            kl=k.split(' ')
            if l[0] in kl[0] and l[1] in kl[1]:
                ot=_dic[k]
                get+=1
        if get!=1:
            ot='unknown command'

    else:
        pass

    print(ot)

全部评论

相关推荐

点赞 1 评论
分享
牛客网
牛客企业服务