I have an issue where I need to use simplejson to write some dictionaries to file using python 2.4 (yes, we're actively trying to upgrade; no, it's not ready yet).
Python 2.4 cannot use the syntax:
with open('data.txt', 'w') as outfile: json.dumps(data, outfile) and I cannot find the correct syntax anywhere. If I try using this:
sov_filename = 'myfile.txt' sov_file = open( sov_filename, 'w' ) filecontents = json.dumps( sov_file ) nothing happens. The file is created, but nothing is in it.
So, does anybody know how to do this for python 2.4?
dumpsaves,loadreads. which one are you trying to do?json.dumps(a write activity) and in the second you are usingjson.loads(a read activity on a file you have opened for writing). Did you mean to do this?