with open(r'C:\Users\Administrator\Desktop\Q2_2.txt', 'r') as f2:dict_line = {}for line1 in f2.readlines():line1 = line1.rstrip()count_line = 0if line1 not in dict_line.keys():for line2 in f2.readlines():line2 = line2.rstrip()if line1 == line2:count_line += 1dict_line[line1] = count_lineprint(dict_line)with open(r'C:\Users\Administrator\Desktop\Q2_3.txt', 'w') as f3:f3.write(str(dict_line))f3.close()f2.close()
添加回答
举报
0/150
提交
取消