Obaja Wijaya
Obaja Wijaya

Reputation: 21

Saving arrays within the loop with different name

I have a question related to the saving an array(.npy).

I have a computation that produces a new array for every loop. Once a while (let's say every 10 steps) I would like to save my output into .npy with a specific name, let's say result_at_step_10.npy. Of course at steps 20, the file name should be result_at_step_20.npy how could I do that in python?

Upvotes: 2

Views: 220

Answers (1)

Ebenezer Isaac
Ebenezer Isaac

Reputation: 802

If renaming the file is what your are looking for, here is the code

import os
os.rename("old_name","new_name")

Upvotes: 2

Related Questions