I have a line that looks like a dictionary like this:
{"h":"hello"}
I would like to convert it into a real dictionary according to the instructions here
>>> import json >>> >>> s = "{'h':'hello'}" >>> json.load(s)
However, I received an error message:
Traceback (last last call): File ", line 1, to file" /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/ init .py ", line 286, returnable in load load (fp.read (),
AttributeError: object 'str' does not have attribute 'read'
What is wrong for my code and how do I convert a string like a dictionary into a real dictionary? Thanks.
source share