title: How to save a dictionary to a file?
body: <p>I have problem with changing a dict value and saving the dict to a text file (the format must be same), I only want to change the <code>member_phone</code> field.</p>
  
  <p>My text file is the following format:</p>
  
  <pre><code>memberID:member_name:member_email:member_phone
  </code></pre>
  
  <p>and I split the text file with:</p>
  
  <pre><code>mdict={}
  for line in file:
      x=line.split(':')
      a=x[0]
      b=x[1]
      c=x[2]
      d=x[3]
      e=b+':'+c+':'+d
  
      mdict[a]=e
  </code></pre>
  
  <p>When I try change the <code>member_phone</code> stored in <code>d</code>, the value has changed not flow by the key, </p>
  
  <pre><code>def change(mdict,b,c,d,e):
      a=input('ID')
      if a in mdict:
          d= str(input('phone'))
          mdict[a]=b+':'+c+':'+d
      else:
          print('not')
  </code></pre>
  
  <p>and how to save the dict to a text file with same format?</p>