题解 | 简单错误记录

import sys
import os

error_list = []
row_list = []
count = []
completed_error_list = []
for line in sys.stdin:
    line = line.replace("\n", "")
    sp = line.split(" ")
    path = sp[0]
    row = sp[1]
    dirStr, ext = os.path.splitext(path)
    file = dirStr.split("\\")[-1]
    
    if len(file) > 16:
        file = file[len(file) - 16:]
    
    if file + " " + row not in completed_error_list:
        error_list.append(file)
        row_list.append(row)

    completed_error_list.append(file + " " + row)



if len(error_list) <= 8:
    for i in range(len(error_list)):
        print(error_list[i],end=" ")
        print(row_list[i],end=" ")
        print(completed_error_list.count(error_list[i] + " " + row_list[i]))
else:
    for i in range(len(error_list)):
        if i < 8:
            count = len(error_list) - 8 + i
            if len(error_list) - i >= 0:
                print(error_list[count],end=" ")
                print(row_list[count],end=" ")
                print(completed_error_list.count(error_list[count] + " " + row_list[count]))


全部评论

相关推荐

2024-12-16 18:04
门头沟学院 平台产品
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务