obj Is that you have to transform into json The object of sort_keys Encoders are sorted by dictionary (a To z) Output Boolindent Indent the display according to the data format Intseparators Set separator strskipkeys Check python Basic type Boolensure_ascii Output Yes No ASCLL code Boolcheck_circular Circular reference checking for container types Bool
2.2 json.dump()
import json
data = {
'name':'name',
'age':20,
}
# speak python Code as json Put it in that file
filename = 'a.txt'
with open (filename,'w') as f:
json.dump(data ,f)
2.3 json.loads()
import json
# use dumps take python Code as json character string
data = json.dumps(data)
# use loads take json Code as python
print(json.loads(data))
2.4 json.load()
import json
data = {
'name':'name',
'age':20
}
filename = 'a.txt'
with open (filename,'w') as f:
json.dump(data,f)
with open (filename) as f_:
print(json.load(f_))