fork download
  1. import re
  2. myUnicode = [u'[X: $1.11] [Y: $3.33] [Z 0/1000] [UUU 111]']
  3. matches = re.findall(r"\[(.*?):?\s(.*?)]", myUnicode[0])
  4. final_dict = {}
  5. for x in matches:
  6. final_dict[x[0]] = x[1]
  7.  
  8. print(final_dict)
Success #stdin #stdout 0.01s 28384KB
stdin
Standard input is empty
stdout
{'X': '$1.11', 'UUU': '111', 'Z': '0/1000', 'Y': '$3.33'}