题解 | #简单错误记录#

简单错误记录

https://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb

import sys
records = []
dic = dict()
for line in sys.stdin:
    file_and_line = line.split("\\")[-1].split(" ")
    address = file_and_line[0][-16:] # last 16 characters
    line = file_and_line[1][:-1] # ditch "\n"
    key = address + " " + line
    if key not in dic:
        dic[key] = 1
        records.append(key)
    else:
        dic[key] += 1
    if len(records) > 8:
        records.pop(0)

for record in records:
    print(record + " " + str(dic[record]))
18行python3代码 简单易懂 这题不配当hard
全部评论

相关推荐

05-27 14:57
西北大学 golang
强大的社畜在走神:27届真不用急,可以搞点项目、竞赛再沉淀沉淀,我大二的时候还在天天打游戏呢
投递华为等公司10个岗位
点赞 评论 收藏
分享
06-05 19:46
已编辑
武汉大学 后端
点赞 评论 收藏
分享
评论
1
3
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务