分类: LINUX
2008-08-20 18:26:30
>>>j=[1,2,3] >>>k=j >>>kisj 1 >>>x=pickle.dumps(k) >>>y=pickle.loads(x) >>>y [1,2,3] >>>y==k 1 >>>yisk 0 >>>yisj 0 >>>kisj 1
>>>f=file(''temp.pkl'',''w'') >>>pickler=pickle.Pickler(f) >>>pickler.dump(a) >>>pickler.dump(b) >>>f.close() >>>f=file(''temp.pkl'',''r'') >>>unpickler=pickle.Unpickler(f) >>>c=unpickler.load() >>>d=unpickler.load() >>>c[2] [3,4,[1,2,[...]]] >>>d[2] [1,2,[3,4,[...]]] >>>c[2]isd 1 >>>d[2]isc 1
>>>f=file(''temp.pkl'',''w'') >>>p=pickle.dumps(f) Traceback(mostrecentcalllast): File"",line1,in? File"/usr/lib/python2.2/copy_reg.py",line57,in_reduce raiseTypeError,"can''tpickle%sobjects"%base.__name__ TypeError:can''tpicklefileobjects