title: Convert string in to dictionary
body: <p>I know It's looks like a dumb question, but anyway.</p>
  
  <p>I'm trying to convert string representation of dictionary back in to dictionary. </p>
  
  <p>My workflow is the following:</p>
  
  <pre><code>d = {1:2}
  s = str(d)
  </code></pre>
  
  <p>When I do:</p>
  
  <pre><code>dict(s)
  </code></pre>
  
  <p>I get:</p>
  
  <blockquote>
    <blockquote>
      <p>ValueError: dictionary update sequence element #0 has length 1; 2 is required</p>
    </blockquote>
  </blockquote>
  
  <p>And when I do:</p>
  
  <pre><code>json.loads(s)
  </code></pre>
  
  <p>I get this:</p>
  
  <blockquote>
    <blockquote>
      <p>ValueError: Expecting property name: line 1 column 1 (char 1)</p>
    </blockquote>
  </blockquote>
  
  <p>How do I convert it back to a dictionary?</p>
  
  <h2>UPDATE:</h2>
  
  <p>I should mention, that the actual data is the following:</p>
  
  <blockquote>
    <p>{'cell_num': u'', 'home_num': u'16047207276', 'registration_country':
    u'US', 'registration_ip': u'71.102.221.29', 'last_updated':
    datetime.datetime(2010, 9, 27, 15, 41, 59), 'address': {'country':
    u'US', 'state': u'CA', 'zip': u'', 'city': u'Santa Barbara', 'street':
    u'', 'confirmed': False, 'created': datetime.datetime(2010, 6, 24, 10,
    23), 'updated': datetime.datetime(2010, 6, 24, 10, 23)},
    'old_home_num': u'16047207276', 'old_cell_num': u''}</p>
  </blockquote>
  
  <p>In that case, option with <code>json.loads</code> and <code>ast.literal_eval()</code> are not appropriate. 
  So I went further and tried to deserialize it with pickle standard python library.</p>
  
  <blockquote>
    <p>import pickle</p>
    
    <p>pickle.loads(data)</p>
  </blockquote>
  
  <p>But then I get:</p>
  
  <blockquote>
    <p>KeyError: '{'</p>
  </blockquote>