Read and write data from file using json

write json data to file

import json

with open('data.json','w+') as f:

    json.dump({"name":"张彪"},f)

read json data from file

import json

with open('data.json','r') as f:
 
    x=json.load(f)
    print(x,type(x))

 

Guess you like

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