json module
-------- any type are converted to a string json
Methods dumps
import json dic={"name":"abc"} data = json.dumps(dic) print(type(data),data)
operation result:
<class 'str'> {"name": "abc"} Process finished with exit code 0
---- operation of the document
Methods loads
import json f_read = open("a","r") data = json.loads(f_read.read()) print(data["name"])
operation result:
abc
Process finished with exit code 0