What is the simplest way to convert a string of keyword=values to a dictionary, for example the following string:
name=\"John Smith\", age=34, height=173.2,
This works for me:
# get all the items matches = re.findall(r'\w+=".+?"', s) + re.findall(r'\w+=[\d.]+',s) # partition each match at '=' matches = [m.group().split('=', 1) for m in matches] # use results to make a dict d = dict(matches)