''' json operations on files ''' import codecs import json test = {"a":1,"b":2} # f = open("1.txt","w") # json.dump(test,f) # Write to the file with codecs.open("1.txt","w") as f: json.dump(test,f) # python object is written to file with codecs.open("1.txt","r") as f: aa = json.load(f) # read from file as python object print(aa) print(type(aa))
The operation of json in python notes on files
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325426033&siteId=291194637
Recommended
Ranking