我創造了這樣一個實例:如何實例對象保存到硬盤驅動器
class some_class():
def __init__(self, aa, bb):
self.a = aa
self.b = bb
def add(self):
self.c = self.a + self.b
return self.c
instance001 = some_class(2,200)
現在我嘗試instance001
保存以備將來使用的硬盤驅動器。
with open('Storage', 'w') as file:
file.write(instance001)
這是行不通的。如何存儲實例?
首選格式爲hdf,但歡迎任何其他想法。
注:熊貓在大量使用。
你可以用泡菜格式存儲對象 –
https://stackoverflow.com/ a/26703304/5250746 –