把内存的数据变成字符串
import json
import pickle
import json import pickle def sayhi(name): print ("hello!",name) info1 ={ 'name':'Lucas', 'age':10, #"func":sayhi } info = ["a","b","c"] f = open("test","w") #f.write(pickle.dumps(info)) f.write(json.dumps(info1)) f.close()
import json import pickle def sayhi(name): print ("hello!",name) f = open("test","r") #data = json.loads(f.read()) data = json.loads(f.read()) #print(data) print(data["name"])
参考文档:http://www.cnblogs.com/alex3714/articles/5161349.html