I have a string, something like this: \"[[\'Cheese\', 72], [\'Milk\', 45], [\'Bread\', 22]]\".
\"[[\'Cheese\', 72], [\'Milk\', 45], [\'Bread\', 22]]\"
I want to convert this to a list. I know I can use eval(s
Here's one way: exec("list = "+foo) This should make a variable 'list' with the list in string converted to a real list. This also works for dictionaries, arrays, bools, etc in strings.