Skip to content

Instantly share code, notes, and snippets.

@rtorres90
Last active June 15, 2017 00:23
Show Gist options
  • Save rtorres90/fd419ca1133a170591d33eb13d1f310b to your computer and use it in GitHub Desktop.
Save rtorres90/fd419ca1133a170591d33eb13d1f310b to your computer and use it in GitHub Desktop.
Handling files with pickles.
import pickle
a,b,c,d=[1],[3],[5],[7]
a.append(2)
b.append(4)
c.append(6)
d.append(8)
with open('test.pk','wb') as fo:
pickle.dump(a,fo)
pickle.dump(b,fo)
pickle.dump(c,fo)
pickle.dump(d,fo)
with open('test.pk', "rb") as f:
while True:
try:
#Insert your code to handle the pickles.
print pickle.load(f)
except EOFError:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment