HJ66 配置文件恢复_字典_字符串
思路:1、把命令和执行对录入一字串字典和二字串字典
2、取字典的可以与输入对比
3、为了保证唯一性,用c常数增加1来判断是否唯一。
4、最后根据c值统一打印输出
1 import sys 2 a=[] 3 for line in sys.stdin: 4 a.append(line.strip().split()) 5 #print(a) 6 d1={"reset":"reset what"} 7 d2={"reset board":"board fault", 8 "board add":"where to add","board delete":"no board at all", 9 "reboot backplane":"impossible","backplane abort":"install first", 10 "he he":"unknown command"} 11 12 for i in a: 13 if len(i)==1: 14 for j in list(d1.keys()): 15 16 if i[0] == j[:len(i[0])]: 17 print(d1[j]) 18 else: 19 print(d2["he he"]) 20 elif len(i)==2: 21 c=0 22 for j in list(d2.keys()): 23 24 newj=j.split() 25 if i[0] == newj[0][:len(i[0])]: 26 if i[1] == newj[1][:len(i[1])]: 27 c+=1 28 str=j 29 if c!=1: 30 print(d2["he he"]) 31 elif c==1: 32 print(d2[str])