>>> import json >>> with open("test", "w") as fp: ... json.dump(l, fp) ... >>> with open("test", "r") as fp: ... b = json.load(fp) ... >>> b [1, 2, 3, 4]