I have a bytes type object like this:
b"{'one': 1, 'two': 2}"
I need to get proper python dictionary from the above bytes type object using python code.
string = b"{'one': 1, 'two': 2}"
d = dict(toks.split(":") for toks in string.split(",") if toks)
But I am getting the below error:
------> d = dict(toks.split(":") for toks in string.split(",") if toks)
TypeError: 'bytes' object is not callable

ast.literal_eval" 'two'"instead of"two").reprof a Python dict andencode-ing it to UTF-8 is really not a good way to store data that you want to load back in later. Much better to use something like JSON or Pickle.