In [33]:
import pickle
In [34]:
a = ['test', 'test2', 'test3']
a
Out[34]:
In [35]:
fileName = "pickleTest"
In [36]:
fileObject = open(fileName, 'wb')
In [37]:
pickle.dump(a, fileObject)
In [38]:
fileObject.close()
In [39]:
fObject = open(fileName, 'rb')
In [40]:
type(fObject)
Out[40]:
In [41]:
fileName
Out[41]:
In [42]:
b = pickle.load(fObject)
In [43]:
fObject.close()
In [44]:
b
Out[44]:
In [45]:
a == b
Out[45]:
In [46]:
with open(fileName, 'rb') as pfile:
c = pickle.load(pfile)
In [47]:
c
Out[47]:
In [48]:
d = ['testa', 'testb', 'testb']
d
Out[48]:
In [49]:
with open(fileName, 'ab') as pfile:
pickle.dump(d, pfile)
In [56]:
with open(fileName, 'rb') as pfile:
e = pickle.load(pfile)
f = pickle.load(pfile)
In [53]:
e
Out[53]:
In [54]:
f
Out[54]:
In [ ]: