Guest User

Untitled

a guest
Feb 25th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. import json
  2. import argparse
  3.  
  4. parser = argparse.ArgumentParser(description='JSON TOOL')
  5.  
  6. parser.add_argument('file')
  7.  
  8. args = parser.parse_args()
  9.  
  10. if args.file:
  11. with open(args.file, 'r', encoding='utf8', errors='strict') as json_file:
  12. obj = json.load(json_file)
  13.  
  14. with open('pretty_'+args.file, 'w', encoding='utf8', errors='strict') as json_file:
  15. json.dump(obj, json_file, indent=4, ensure_ascii=False)
Add Comment
Please, Sign In to add comment