题解 | #配置文件恢复# 为方便使用startswith
配置文件恢复
https://www.nowcoder.com/practice/ca6ac6ef9538419abf6f883f7d6f6ee5
one = "reset"
two1 = ["reset", "board", "board", "reboot", "backplane"]
two2 = ["board", "add", "delete", "backplane", "abort"]
fail = "unknown command"
r = "reset what"
a = ["board fault", "where to add", "no board at all", "impossible", "install first"]
while True:
try:
string = input().split(" ")
if string in [["b", "a"], ["r", "b"]] or not string[0]:
print(fail)
else:
if len(string) == 1:
if one.startswith(string[0]):
print(r)
else:
print(fail)
elif len(string) == 2:
if not string[1]:
print(fail)
continue
for i in range(5):
if two1[i].startswith(string[0]) and two2[i].startswith(string[1]):
print(a[i])
break
else:
print(fail)
else:
print(fail)
except:
break
#刷题#
查看17道真题和解析
