Python Language Storing data in a file

Download Python Language for free


The following snippet encodes the data stored in d into JSON and stores it in a file (replace filename with the actual name of the file).

import json

d = {
    'foo': 'bar',
    'alice': 1,
    'wonderland': [1, 2, 3]

with open(filename, 'w') as f:
    json.dump(d, f)
kivy - Cross-platform Python Framework for NUI Development