题解 | #简单错误记录#
简单错误记录
http://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb
dic = {}
while True:
try:
path, line = input().split()
# 获取文件名
name = ''
for c in path[::-1]:
if c == '\\':
break
name += c
# 长度超过16,截断,然后翻转字符串
if len(name) > 16:
name = name[:16][::-1]
else:
name = name[::-1]
# 将记录保存到字典dic中
key = (name, line)
if key not in dic:
dic[key] = 1
else:
dic[key] += 1
except:
break
# 输出最后8条记录,从倒数第8个开始输出
for i, record in enumerate(dic.items()):
# 总数减当前索引大于8,说明还没到倒数第8个,则不输出
if len(dic) - i > 8:
continue
print(record[0][0], record[0][1], record[1])