Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将JSON转换为Python字典(寻找更好的方法)_Json_Python 3.x - Fatal编程技术网

将JSON转换为Python字典(寻找更好的方法)

将JSON转换为Python字典(寻找更好的方法),json,python-3.x,Json,Python 3.x,所以我已经写了这段代码,但感觉一定有更好的方法: # json_data is a passed in JSON object str_json = str(json_data) # convert the string to python dictionary new_dict = json.loads(str_json) 这是你的朋友 json.loads 这是你应该使用的方法。这是最好的办法 他是你的朋友 json.loads 这是你应该使用的方法。这是最好的办法 哦,所以根本不需要

所以我已经写了这段代码,但感觉一定有更好的方法:

# json_data is a passed in JSON object
str_json = str(json_data)
# convert the string to python dictionary
new_dict = json.loads(str_json)
这是你的朋友

json.loads
这是你应该使用的方法。这是最好的办法

他是你的朋友

json.loads

这是你应该使用的方法。这是最好的办法

哦,所以根本不需要转换成字符串。很高兴知道!哦,所以根本不需要转换成字符串。很高兴知道!