题解 | #简单错误记录#
简单错误记录
http://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb
import sys
d=dict()
for line in sys.stdin:
error_info=line.strip().split('\\')[-1].split(' ')
file_name=error_info[0][-16:]
error_line=error_info[1]
info_key=f'{file_name} {error_line}'
d.update({info_key:1 if d.get(info_key) is None else d[info_key]+1})
for k in list(d.keys())[-8:]:#只打印最后8条
print(f'{k} {d[k]}')