1 import simplejson as json
 2 
 3 with open(r'C:\Users\Desktop\test.txt', 'r' ) as f1, open(r'C:\Users\Desktop\newtest.txt', 'w') as f2:
 4     alist = []
 5     new_dict = {}
 6     for i in f1.readlines():
 7         alist.append(json.loads(i))
 8     
 9     for i in range(len(alist)):
10         if not new_dict.has_key(alist[i]['key']):
11             new_dict[alist[i]['key']] = True
12             f2.writelines(json.dumps(alist[i]))
13             f2.write('\n')

欢迎指正…… 

2017-09-13

相关文章:

  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2022-01-07
猜你喜欢
  • 2022-12-23
  • 2021-06-19
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
  • 2018-06-22
相关资源
相似解决方案