把内存的数据变成字符串
import json
import pickle
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
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()
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
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