I am new to python and would like to export some nested lists and some variables in a .txt file in python, and to be able to retrieve these data and to import them later in python.
For instance,
my_list1 = [[[-1, 1, 0, -1]], [[-1, 1, 0, -1]]]
my_list2 = [[[2, 1, 1], [1, 1, 0, 2]], [[2, 1, 1, 0], [0, 2, 1, 1]]]
my_var = 3
my_var2 = 7
I tried
with open("file.txt", "w") as f:
for ( my_list1 , my_list2) in zip(my_list1 , my_list2 ):
f.write("{1},{2}\n".format(my_list1 , my_list2))
but I don't know how to also export my variables with it, and how to import and retrieve each data after.
Thanks