Retrieving data from a file

Download python eBook

Example

The following snippet opens a JSON encoded file (replace filename with the actual name of the file) and returns the object that is stored in the file.

import json

with open(filename, 'r') as f:
    d = json.load(f)

Stats

Contributors: 2
2016-06-13
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook