python对象序列化pickle

import pickle

class A:
users = {}
c = 1
def get_self(self):
return self
def n(self):
return 1 def pick_str_to_obj(self):
return 'xiaoming'
a = A()
----------------------------------------------
dumpss = pickle.dumps(a)
reversess = pickle.loads(dumpss)
----------------------------------------------
with open('aaad.txt', 'wb') as f:
picklestring = pickle.dump(a, f) with open('aaad.txt', 'rb') as f:
obj = pickle.load(f)
print(obj.n())

ps:多个对象咋办??

list, dict也是对象哟

上一篇:我用 tensorflow 实现的“一个神经聊天模型”:一个基于深度学习的聊天机器人


下一篇:UWP 解决Webview在Pivot里面无法左右滑动的问题