, numpy save . ,
sampleList1=['z','x','a','b']
sampleList2=[[1,2],[4,5]]
, , .npy
def saveList(myList,filename):
np.save(filename,myList)
print("Saved successfully!")
def loadList(filename):
tempNumpyArray=np.load(filename)
return tempNumpyArray.tolist()
>>> saveList(sampleList1,'sampleList1.npy')
>>> Saved successfully!
>>> saveList(sampleList2,'sampleList2.npy')
>>> Saved successfully!
>>> loadedList1=loadList('sampleList1.npy')
>>> loadedList2=loadList('sampleList2.npy')
>>> loadedList1==sampleList1
>>> True
>>> print(loadedList1,sampleList1)
>>> ['z', 'x', 'a', 'b'] ['z', 'x', 'a', 'b']