title: Replace Python dictionary value with new value
body: <p>I'm using the values of a file to create populate a dictionary. I created the file using a function:</p>
  
  <pre><code>def save_dict_to_file(filename, dictionary):  # done
      with open(filename, 'w') as w:
          for key in dictionary:
              w.write("(")
              w.write(key)
              w.write(")")
              w.write("@(")
              w.write(str(dictionary[key]))
              w.write(")")
              w.write("\n")
  
  print (save_dict_to_file('save_dict_to_file_example.txt', {'abc':3,'def':'ghj'}))
  </code></pre>
  
  <p>Original file content:</p>
  
  <pre><code>(abc)@(3)
  (def)@(ghj)
  </code></pre>
  
  <p>The 3 is an integer. I'd like to maintain the data type in the dictionary but currently the dictionary is returning '3' as a string:</p>
  
  <pre><code>{'abc': '3', 'def': 'ghj'}
  </code></pre>
  
  <p>Here is my full code: </p>
  
  <pre><code>def load_dict_from_file(filename):
      with open(filename, 'r') as r:
          dictionary = dict()
          file_contents=r.readlines()
          for line in file_contents:
              #line=line.strip()
              index=line.index('@')
              key=line[1:index-1] #before the @
              value=line[index+2:-2] #after the @
              value=value.strip()
              dictionary[key]=value
              for character in key,value:
                  if character.isdigit():
                      index_character=character.index
                      new_character = int(character)
                  else:
                      continue
      print(dictionary)
  </code></pre>
  
  <p>How do I delete the old character from the dictionary and replace it with the new one? </p>