| 1234567891011121314151617181920212223242526 |
- # 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)
|