题解 | #配置文件恢复#
配置文件恢复
https://www.nowcoder.com/practice/ca6ac6ef9538419abf6f883f7d6f6ee5
while 1: try: s=input().split( ) #print(s) d={ 'reset board':'board fault', 'board add':'where to add', 'board delete':'no board at all', 'reboot backplane':'impossible', 'backplane abort':'install first' } if len(s)==1: if s[0]=='reset'[:len(s[0])]: print('reset what') else: print('unknown command') elif len(s)>1: order_match=[] for i in d.keys(): order=i.split() if s[0]==order[0][:len(s[0])] and s[1]==order[1][:len(s[1])]: order_match.append(i) #print(order_match) if len(order_match)==1: print(d[order_match[0]]) elif len(order_match)!=1: print('unknown command') except: break