标签:pickle json str print 序列化 data
import pickle
hello = 'hello world'
data = pickle.dumps(hello) #pickle.dumps把任意对象序列化成一个bytes(字节数)
print(data)
data1 = pickle.loads(data) #pickle.loads将字节数反序列化
print(data1)
import json
data = {
'hello':123,
'nihao':'word'
}
str_json = json.dumps(data) #json.dumps将字典类型序列化为字符串类型
print(str_json,type(str_json))
dicts = json.loads(str_json)#json.loads将字符串类型反序列化为字典类型
print(dicts,type(dicts))
标签:pickle,
json,
str,
print,
序列化,
data
From: https://www.cnblogs.com/striveforward/p/18259658