Home Blog Python Notes

Write data to file on disk in json format

Published:


import json

a = {'hello': 'world'}
b = 'mohit'

with open('C:\\Users\\mohit\\temp\\filename.json', 'wt') as handle:
    json.dump(a, handle)
Comment