题解 | #配置文件恢复#
配置文件恢复
https://www.nowcoder.com/practice/ca6ac6ef9538419abf6f883f7d6f6ee5
dic = {'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'}
dic_k = [['reset','board'],['board','add'],['board','delete'],['reboot','backplane'],['backplane','abort']]
while True:
try:
ent = list(input().split())
if len(ent) == 1:
if ent[0] == 'reset'[:len(ent[0])]:
print(dic['reset'])
else:
print('unknown command')
elif len(ent) == 2:
st = ''
key = []
for i in dic_k:
if ent[0] == i[0][:len(ent[0])] and ent[1] == i[1][:len(ent[1])]:
st = i[0] + ' ' + i[1]
key.append(st)
if len(key) == 1:
print(dic[key[0]])
else:
print('unknown command')
else:
print('unknown command')
except:
break
查看13道真题和解析