从报错里认故障类型

👁️ 1 人浏览 💬 0 人评论 ❤️ 添加收藏

五条报错各属于哪一类:端口 / 路径 / 日志(运行时)。分一分、数一数:

msgs = ["OSError: [Errno 98] Address already in use", "FileNotFoundError: [Errno 2] No such file or directory: '模板/首页.html'", "KeyError: 'title'", "OSError: [Errno 99] Cannot assign requested address", "FileNotFoundError: [Errno 2] No such file or directory: '日志/访问.txt'"]
kinds = []
for m in msgs:
    if "Errno 98" in m or "Errno 99" in m:
        kinds.append("端口")
    elif "FileNotFound" in m:
        kinds.append("路径")
    else:
        kinds.append("日志")
print(",".join(kinds) + "/" + str(kinds.count("路径")))
提交你的答案
请登录后提交答案。
去登录
代码编辑器
Ctrl + Enter 运行
本次输入:
输出:

                        
👩‍🏫
AI
💬 题目评论

全部评论