import simplejson as json with open(r'C:\Users\Desktop\test.txt', 'r' ) as f1, open(r'C:\Users\Desktop\newtest.txt', 'w') as f2:
alist = []
new_dict = {}
for i in f1.readlines():
alist.append(json.loads(i)) for i in range(len(alist)):
if not new_dict.has_key(alist[i]['key']):
new_dict[alist[i]['key']] = True
f2.writelines(json.dumps(alist[i]))
f2.write('\n')
欢迎指正……
2017-09-13