I declare a string variable b, but I no matter use what method can convert it into a dictionary type
B="{' d ':' none ', 'in the' : 'none', 'wa' : 'none', 'playpaws' :' play888 '}"
# dlist=json. Loads (b) results: print (type (dlist)) & lt; The class 'STR' & gt;
# dlist=eval (b) results: print (type (dlist)) & lt; The class 'STR' & gt;
Screenshots are as follows:



CodePudding user response:
Personally, python and json on the definition and use of single and double quotes are different,Try the following code:
import json
B='{" d ":" none ", "in" : "none", "wa" : "none", "playpaws" : "play888"}'
Dlist=json. Loads (b)
Print (dlist)
Print (dlist [' wa '])