I have unicode u\"{\'code1\':1,\'code2\':1}\" and I want it in dictionary format.
I want it in {\'code1\':1,\'code2\':1} format.
I
EDIT: Turns out my assumption was incorrect; because the keys are not wrapped in double-quote marks ("), the string isn't JSON. See here for some ways around this.
I'm guessing that what you have might be JSON, a.k.a. JavaScript Object Notation.
You can use Python's built-in json module to do this:
import json
result = json.loads(u"{'code1':1,'code2':1}") # will NOT work; see above