how to create a dictionary from a set of properly formatted tuples in python -
is there simple way create dictionary list of formatted tuples. e.g. if like:
d={"responsestatus":"success","sessionid":"01234","userid":2000004904} this creates dictionary called d. however, if want create dictionary string contains same string, can't that
res=<some command returns {"responsestatus":"success","sessionid":"01234","userid":2000004904}> print res # returns {"responsestatus":"success","sessionid":"01234","userid":2000004904} d=dict(res) this throws error says:
valueerror: dictionary update sequence element #0 has length 1; 2 required
i strongly suspect have json on hands.
import json d = json.loads('{"responsestatus":"success","sessionid":"01234","userid":2000004904}') would give want.
Comments
Post a Comment