title: Python - Reading a text file into dictionary
body: <p>I recently started programming with Python and i've encountered quite a big problem with one of my functions. I'm trying to take data from a text file in the form of a list, into a dictionary in Python. The format of the text file is consistently formatted as is displayed below:</p>
  
  <pre><code>@text {
      n = "test1",
      r = ["B:1", "G:2", "H:3", "O:4", "S:5", "W:6"],
      t = ["G:1","H:2"]
  }
  </code></pre>
  
  <p>Using the three keys: n, r and t; how would I go about reading their values from the text file into my dictionary using Python? </p>
  
  <p>So far, I have managed to develop the following code with no success, not knowing where i've gone wrong despite attempting to research this all over the web.</p>
  
  <pre><code>f = open('text.txt', 'r')
  newDict = {}
  for line in f:
      n, r, t = line.strip().split('=')
      newDict[k.strip()] = v.strip()
  </code></pre>
  
  <p>Am I along the right lines with this or completely off the mark? The whole concept of reading multiple keys and values into a dictionary from a text file has me completely confused when it comes to the process of importing/converting the file.</p>
  
  <p>Any help with this would be greatly appreciated - thank you in advance.</p>