Back to cheatsheets

Python

Save JSON to file in Python

Save data to json file in python.

import json
 
data = [1, 2, 3];
 
with open('data.json', 'w') as f:
    json.dump(data, f)