1.字典的序列化与反序列化
a.序列化:把python的数据类型转为str类型的过程
b.反序列化:str的类型转为python的数据结构
需要导入的包:
import json
import requests #在pychram 中进行包的导入安装file-->settings--->Project Interpreter
示例:
dict1 = {‘name‘:‘rzq‘,‘age‘:18}
#序列化:dict -->str
dict_str =json.dumps(dict1)
print(‘序列化后的结果信息:‘)
print(dict_str,type(dict_str))
#反序列化:str --->dict
str_dict =json.loads(dict_str)
print(‘反序列化后的结果信息:\n‘,str_dict,type(str_dict))
结果:

2.列表的序列化与反序列化
原文:https://www.cnblogs.com/renzhiqiang/p/11269319.html