Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2016
1,023
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. import json, os
  2. d = {}
  3. filenames = sorted([fn for fn in os.listdir() if fn.endswith('.json')])
  4. for filename in filenames:
  5.     f = open(filename)
  6.     nd = json.load(f)
  7.     # option a:
  8.     d[filename] = nd
  9.     # option b:
  10.     # d.update(nd)
  11. f = open('result.json', 'w')
  12. json.dump(d, f)
  13. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement