I agree with another response -- the best you can do is to json.dump
each dict
individually and write the commas and newlines manually. Here is how I would do that:
import json
data = [
{"key01":"value","key02":"value"},
{"key11":"value","key12":"value"},
{"key21":"value","key22":"value"}
]
import json
with open('file.json', 'w') as fp:
fp.write(
'[' +
',
'.join(json.dumps(i) for i in data) +
']
')
Result:
[{"key01": "value", "key02": "value"},
{"key12": "value", "key11": "value"},
{"key22": "value", "key21": "value"}]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…