Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import os
- THIS_FOLDER = os.path.dirname(os.path.abspath(__file__))
- my_file = os.path.join(THIS_FOLDER, 'info.json')
- with open(my_file) as f:
- # data-load
- dataLoad = json.load(f)
- for info in dataLoad['information']:
- # print data
- print(info['name'], '-' ,info['zip-code'])
- # write data in file:
- # ----------------------
- with open('E:/code/python/begin/41_json/write_data_in_file.json', 'w') as f1:
- json.dump(dataLoad, f1, indent=2)
Advertisement
Add Comment
Please, Sign In to add comment