json serialization

Serialization: --------json.dumps

import json
aa={
'name':'zhow',
'age':26,
'sex':'m'

}
f=open('person.text','w')
print(json.dumps(aa))
f.write(json.dumps(aa))

反序列化:-------json.loads
import json 
f=open('person.text','r')
aa=json.loads(f.read())
print(aa['age'])

json can only process some simple data, which can be used in all languages

pickle is similar to json usage, it can handle complex data and can only be used in python



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325154168&siteId=291194637