import json # json反序列化 # json_str = '{"name":"qiyue","age":18}' # student = json.loads(json_str) # print(type(student)) # <class 'dict'> # print(student) # {'name': 'qiyue', 'age': 18} # print(student['name']) # qiyue # json_str2 = '[{"name":"qiyue","age":18,"flag":false},{"name":"zouke","age":19}]' # student = json.loads(json_str2) # print(type(student)) # <class 'list'> # print(student) # [{'name': 'qiyue', 'age': 18, 'flag': False}, {'name': 'zouke', 'age': 19}] # print(student[0]['name']) # qiyue #json序列化 student = [ {'name': 'qiyue', 'age': 18, 'flag': False}, {'name': 'zouke', 'age': 19} ] json_str = json.dumps(student) print(type(json_str)) # <class 'str'> print(json_str) # [{"name": "qiyue", "age": 18, "flag": false}, {"name": "zouke", "age": 19}]