题解 | #配置文件恢复#
配置文件恢复
https://www.nowcoder.com/practice/ca6ac6ef9538419abf6f883f7d6f6ee5
ini = { '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' } while True: try: n = input().split() p = [] for k,v in ini.items(): kl = k.split() if len(n) == 1 and len(kl)==1 and kl[0].startswith(n[0]): p.append(v) elif len(n)==2 and len(kl)==2 and kl[0].startswith(n[0]) and kl[1].startswith(n[1]): p.append(v) if len(p) >1 or len(p)==0: print('unknown command') elif len(p) == 1: print(p[0]) except: break