题解 | #配置文件恢复#还行吧
配置文件恢复
http://www.nowcoder.com/practice/ca6ac6ef9538419abf6f883f7d6f6ee5
while True:
try:
str_input = input()
order_dict = {
'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',
}
others = 'unknown command'
n = len(str_input.split())
if n == 1:
if 'reset'.startswith(str_input):
print('reset what')
else:
print(others)
elif n == 2:
times = 0
index = 0
str1, str2 = str_input.split()
for i in range(1, len(order_dict.keys())):
order1, order2 = list(order_dict.keys())[i].split()
if order1.startswith(str1) and order2.startswith(str2):
times += 1
index = i
if times == 1:
print(order_dict[list(order_dict.keys())[index]])
else:
print(others)
else:
print(others)
except:
break