Write a NumPy program to save a given array to a binary file
import numpy as np import os a = np.arange(20) np.save('temp_arra.npy', a) print("Check if 'temp_arra.npy' exists or not?") if os.path.exists('temp_arra.npy'): x2 = np.load('temp_arra.npy') print(np.array_equal(a, x2))
Sample Output:
Check if 'temp_arra.npy' exists or not? True
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer