1dictionary = {'someKey' : 'someValue'}
2file_path = 'somePathToFile/someFileName.py'
3with open(file_path, 'w') as output_file:
4 print(dictionary, file=output_file)
1d = {}
2with open("file.txt") as f:
3 for line in f:
4 (key, val) = line.split()
5 d[int(key)] = val
1# Writing dictionary as json
2import json
3d = {'guitar':'Jerry', 'drums':'Mickey' }
4json.dump(d, open('1.json', 'w'))