python pickle save dictionary, a list of tuples is lost
<p>I'm new to Python. I tried to save my results but failed. Could anyone help me to correct my code?</p>

<pre><code>parameter = k ##(k is an number)
L = [(1,matrix1), (2,matrix2), (2,matrix2),...]
</code></pre>

<p>First I make a dictionary to put my result</p>

<pre><code>My_dict = {'parameter':k, 'my_list': L}
</code></pre>

<p>I used the following code to save and read:</p>

<pre><code>import pickle
output = open('result.pkl', 'wb')
pickle.dump(My_dict, output, -1)
output.close()
</code></pre>

<p>(I check my dictionary here and everything is correct till now)</p>

<p>But when I try to read my data:</p>

<pre><code>pkl_file = open('result.pkl', 'rb')
res = pickle.load(pkl_file)
pprint.pprint(res)
</code></pre>

<p>I found my L is empty as shown below:    </p>

<pre><code>'parameter': k,
'L': []
</code></pre>

<p>Where part of my code is wrong? Can any one help, please?</p>