Skip to content

Instantly share code, notes, and snippets.

@felipessalvatore
Created October 25, 2016 13:25
Show Gist options
  • Save felipessalvatore/05ac88496caa2835f74bbaa2b4972dd6 to your computer and use it in GitHub Desktop.
Save felipessalvatore/05ac88496caa2835f74bbaa2b4972dd6 to your computer and use it in GitHub Desktop.
Basic pickle manipulation in python
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>saving
import pickle
a = 1
b = [23,4,4,22]
c = "Hello"
d = "Baby I got me"
e = 99999
f = open("teste.pickle", 'wb')
di ={'a':a, 'b':b, 'c':c, 'd':d, 'e':e}
pickle.dump(di,f)
f.close()
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>loading
import pickle
with open("teste.pickle","rb") as s:
d = pickle.load(s)
pass
print(d['a'])
print(d['b'])
print(d['c'])
print(d['d'])
print(d['e'])
del d # hint to help gc free up memory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment