一个简单的例子,演示了怎么使用cPickle存储对象
#!/usr/bin/python #Filename:pickling.py import cPickle as p shoplistfile = 'shoplist.data' shoplist = ['apple', 'mango', 'carrot'] f = file(shoplistfile, 'w') p.dump(shoplist, f) f.close() del shoplist f = file(shoplistfile) storedlist = p.load(f) print storedlist
原文地址:http://blog.csdn.net/nyist327/article/details/46522071