You can use
pickle
module for that.
This module have two methods, - Pickling(dump): Convert Python objects into string representation.
- Unpickling(load): Retrieving original objects from stored string representstion.
import pickle
l = [1,2,3,4]
with open("test.txt", "wb") as fp: #Pickling
pickle.dump(l, fp)
with open("test.txt", "rb") as fp: # Unpickling
b = pickle.load(fp)
b
[1, 2, 3, 4]
No comments:
Post a Comment