Python 知心的利用
json.loads(employee_string)
就可以了。
首先须要做的便是导入 JSON 库。

#include json library import json
对当代程序员来说,JSON 数据构造基本上是非常常见的数据构造了,险些所有措辞都可以处理。
#include json libraryimport json#json string dataemployee_string = '{"first_name": "Michael", "last_name": "Rodgers", "department": "Marketing"}'#check data type with type() methodprint(type(employee_string))#convert string to objectjson_object = json.loads(employee_string)#check new data typeprint(type(json_object))
上面的代码就可以直接让 Python 把字符串转换为 JSON 的工具了。
当我们完成转换后,就可以对 JSON 的工具进行干系操作了。