title: String containing list and other data types to dictionary without changing the data type in python
body: <p>I have one string as below:</p>
  
  <pre><code>key_val = "count=2, name=['hello', 'hi'], word='Dial::100', roll=12"
  </code></pre>
  
  <p>I need to get the dictionary from the string as below:</p>
  
  <pre><code>d_key_val = {'count'=2, 'name'=['hello', 'hi'], 'word'='Dial::100', 'roll'=12}
  </code></pre>
  
  <p>I tried with the following:</p>
  
  <pre><code>regx = r'(?P&lt;key&gt;\w+)=(?P&lt;value&gt;\[.+?\]|\d+|\S+)'
  r_key_val = re_findall(regx, key_val)
  for key, value in r_key_val:
          d_key_val[key] = value
  </code></pre>
  
  <p>But it is storing values as all string:</p>
  
  <pre><code>d_key_val = {'count'='2', 'name'="['hello', 'hi']", 'word'="'Dial::100'", 'roll'='12'}
  </code></pre>
  
  <p>Is there any way or regex to store the values as same data type as it has in string?</p>