import pickle data1 = [1,2,3,4] with open("data1.txt", "w") as data1_file: print(data1, file=data1_file, end='') with open("data1.txt") as data1_file: print(data1_file.read()) with open('mydata.pickle', 'wb') as mysavedata: pickle.dump([1,2,'three'], mysavedata) with open('mydata.pickle', 'rb') as myresttoredata: a_list = pickle.load(myresttoredata) print(a_list)