>>> import pickle
>>> data = [{'name':'lady gaga','city':'new york','age':24},{'name':'luna maya','city':'denpasar','age':27}]
>>> output = open('lola.txt', 'w')
>>> pickle.dump(data, output)
>>> output.close()Load a data from a file:
>>> import pickle, pprint
>>> pkl = open('lola.txt', 'r')
>>> data = pickle.load(pkl)
>>> pprint.pprint(data)
No comments:
Post a Comment