, , gzip
.
, ,
import gzip, pickle
with gzip.open('test.pklz', 'wb') as ofp:
pickle.dump([1,2,3], ofp)
with open('test.pklz', 'rb') as ifp:
print(pickle.load(ifp))
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
_pickle.UnpicklingError: invalid load key, ''.
But, if the pickle file is opened with gzip
, everything is harmonious
with gzip.open('test.pklz', 'rb') as ifp:
print(pickle.load(ifp))
[1, 2, 3]
source
share