Created
October 25, 2016 13:25
-
-
Save felipessalvatore/05ac88496caa2835f74bbaa2b4972dd6 to your computer and use it in GitHub Desktop.
Basic pickle manipulation in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>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