初级
配置文件恢复
未完成
初级参考
完整示例代码供参考,建议自己理解后重新输入
def solve(data):
CMDS = {
'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',
}
for line in str(data).strip().split(','):
parts = line.strip().split()
matches = []
if len(parts) == 1:
for k in CMDS:
ks = k.split()
if len(ks) == 1 and ks[0].startswith(parts[0]):
matches.append(k)
elif len(parts) == 2:
for k in CMDS:
ks = k.split()
if len(ks) == 2 and ks[0].startswith(parts[0]) and ks[1].startswith(parts[1]):
matches.append(k)
if len(matches) == 1:
print(CMDS[matches[0]])
else:
print('unknown command')
示例
输入
solve('reset,reset board,board a,reboot backplane,board,abort')
期望输出
reset what board fault where to add impossible unknown command unknown command
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199