How to use `numpy.savez` in a loop for save more than one array?

前端 未结 4 963
一生所求
一生所求 2020-12-29 09:42

From a loop I\'m getting an array. I want to save this arrays in a tempfile. The problem is that np.savez only saves the last array from the loop.

4条回答
  •  春和景丽
    2020-12-29 10:41

    You can use the *args arguments to save many arrays in only one temp file.

    np.savez(tmp, *getarray[:10])
    

    or:

    np.savez(tmp, *[getarray[0], getarray[1], getarray[8]])
    

提交回复
热议问题