题解 | #配置文件恢复#
配置文件恢复
https://www.nowcoder.com/practice/ca6ac6ef9538419abf6f883f7d6f6ee5
d = { '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: cmd = input().split(' ') if len(cmd) == 1: if cmd[0] in 'reset'[0:len(cmd[0])]: print(d['reset']) else: print('unknown command') elif len(cmd) == 2: matched = [] for ori_cmd in ['reset board','board add','board delete','reboot backplane','backplane abort']: o = ori_cmd.split(' ') if cmd[0] in o[0][0:len(cmd[0])] and cmd[1] in o[1][0:len(cmd[1])]: matched.append(ori_cmd) if len(matched) == 1: print(d[matched[0]]) else: print('unknown command') else: print('unknown command') except: break