I should communicate with an online service that sends me the following data urlencoded:
data_to_process = {...}
args = {'args0': data_to_process, 'action': 'save'}
result = urllib2.urlopen(..., urllib.urlencode(args), ...)
The main data of interest is stored in the data_to_process dictionary. I would like to get back the original dictionary that’s supposed to contain only string, numeric and boolean values. How can you achieve this?
I’ve tried
eval(dict_str,{'__builtins__': None})
but this fails for False values (and who knows what else).
thanks for any ideas!
Use
ast.literal_eval: