题解 | #简单错误记录#
简单错误记录
http://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb
#将所有输入保存到lines lines =[] # while 1: try: line = input().strip() lines.append(line) except EOFError: break record_Num =[] record =[] #统计 for line in lines: filename = line.split(' ')[0].split('\\')[-1].strip() if len(filename)>16: filename = filename[len(filename)-16:len(filename)] cloum_num = line.split(' ')[1].strip() error_path = filename+" "+cloum_num if error_path in record: index = record.index(error_path) record_Num[index]+=1 else: record.append(error_path) record_Num.append(1) #输出 sindex = 0 if len(record)>=8: sindex = len(record)-8 while sindex<len(record): print(record[sindex]+" "+ str(record_Num[sindex])) sindex += 1