Doing what you want is possible. But you shoul use instead le library pickle
.
First import picle
import pickle
For saving the variable you can use this
def saver(obj): #Pass the object you want to save
pickle_file = open("data.pickle", "wb")
pickle.dump(obj,pickle_file)
pickle_file.close
Then to load :
def loader():
pickle_file = pickle_file = open("data.pickle", "rb")
data = pickle.load(pickle_file)
pickle_file.close()
return data
Exemple:
saver([1,2,3,4])
liste = loader()
print(liste)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…