Skip to content

Commit

Permalink
create basic34
Browse files Browse the repository at this point in the history
  • Loading branch information
Mofan Zhou committed Jun 17, 2016
1 parent c24aa52 commit 2c22923
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions basic/34_pickle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# View more python learning tutorial on my Youtube and Youku channel!!!

# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
# Youku video tutorial: http://i.youku.com/pythontutorial

import pickle

a_dict = {'da': 111, 2: [23,1,4], '23': {1:2,'d':'sad'}}

# pickle a variable to a file
file = open('pickle_example.pickle', 'wb')
pickle.dump(a_dict, file)
file.close()

# reload a file to a variable
with open('pickle_example.pickle', 'rb') as file:
a_dict1 =pickle.load(file)

print(a_dict1)







0 comments on commit 2c22923

Please sign in to comment.