Skip to content

Instantly share code, notes, and snippets.

@btel
Created October 3, 2013 13:39
Show Gist options
  • Select an option

  • Save btel/6809990 to your computer and use it in GitHub Desktop.

Select an option

Save btel/6809990 to your computer and use it in GitHub Desktop.
{
"a": 1,
"nested_dictionary": {
"c": 1,
"d": 2
},
"b": 2,
"list": [
1,
2,
3
]
}
#!/usr/bin/env python
#coding=utf-8
import json
parameters = {'a' : 1,
'b' : 2,
'list': [1,2,3],
'nested_dictionary' : {'c': 1, 'd': 2}}
# write to file
with file('parameters.json', 'w') as fid:
json.dump(parameters, fid, indent=4)
# read from file
with file('parameters.json') as fid:
loaded_parameters = json.load(fid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment