#使用正则表达式匹配,思路非常简单,命令分单字符串、双字符串和其他字符串,分别考虑就行
import re
min_zx = {"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",}
def is_ok(strr):
b, outt, flagg, m_l =None, "", 0, strr.split(" ") #定义输出的内容、匹配多个的标签、输入命令转化为列表
if len(m_l) == 1:
b = re.compile("^{}[a-z]*$".format(strr))
elif len(m_l) == 2:
b = re.compile(r"^{}[a-z]*\s{}[a-z]*$".format(m_l[0],m_l[1]))
if b:
for i in min_zx.keys():
if b.match(i):
outt = min_zx[i]
flagg += 1
if flagg == 1:
return outt
else:
return "unknown command"
return "unknown command"
while True:
try:
a = input()
except:
break
else:
print(is_ok(a))