1# dump()
2
3import pickle
4
5data1 = {'a': [1, 2.0, 3, 4+6j],
6 'b': ('string', u'Unicode string'),
7 'c': None}
8
9selfref_list = [1, 2, 3]
10selfref_list.append(selfref_list)
11
12output = open('data.pkl', 'wb')
13
14# Pickle dictionnary using protocol 0.
15pickle.dump(data1, output)
16
17# Pickle the list using the highest protocol available.
18pickle.dump(selfref_list, output, -1)
19
20output.close()