title: The difference between `str` and `pickle` serialization methods for dictionary values
body: <p>If I want to save a Dictionary structure to a file and read this Dictionary from the file directly later, I have two methods but I do not know the differences between the two methods. Could anyone explain it?
  Here is a simple example. Suppose this is my dictionary:</p>
  
  <pre><code>D = {'zzz':123,
       'lzh':321,
       'cyl':333}
  </code></pre>
  
  <p>The first method to save it to the file:</p>
  
  <pre><code>with open('tDF.txt','w') as f: # save
     f.write(str(D) + '\n')
  with open('tDf.txt','r') as f:
     Data = f.read() # read. Data is string
  Data = eval(Data) # convert to Dictionary structure format
  </code></pre>
  
  <p>The second method (using pickle):</p>
  
  <pre><code>import pickle
  with open('tDF.txt','w') as f: # save
     pickle.dump(D,f)
  with open('tDF.txt','r') as f:
     D = pickle.load(f) # D is Dictionary structure format
  </code></pre>
  
  <p>I think the first method is much simple. What is the differences?</p>
  
  <p>Thanks!</p>