Home > other >  Python how to temporarily keep a running list of all the data, so that the next run initialization
Python how to temporarily keep a running list of all the data, so that the next run initialization

Time:05-20

The problem is that I now have a loop iteration code, inside some list used to save all the optimal location and the optimal value of the iterative process, but if I don't have to loop iteration, so every time at the start of the list of all data will be initialized to 0. I want to have a way to keep one iteration is completed, in the program of the list (or number),

CodePudding user response:

Can only be run at a time to keep things to the local Excel or something, read again next time, large proportion of the new data will run a bit faster

CodePudding user response:

The
Morningstar quotes 1 floor? Response:
can only be run at a time to keep things to the local Excel or something, read again next time, large proportion of the new data will run a bit faster
but my teacher says can save the data in some way, such as the next with the load when the line

CodePudding user response:

You mean run once after a set of data, this set of data at the next rerun when needed? It can only be saved to the local first, run read again next time,

CodePudding user response:

If it is stored in the memory, can copy a list on a temporary variable
If you want to save in the disk, can be serialized to a file, such as:

 import pickled 

A=,4,5,6,7,8,9 [3]

# in the file
Pickle. Dump (a, open (r "c: \ xx. D," 'wb))

# from the file
X=pickle. The load (open (r "c: \ xx. D," 'rb'))
Print (x)
  • Related