题解 | #配置文件恢复# 反正都双列表了可以更彻底一点
配置文件恢复
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
查看17道真题和解析