w3resource logo
Python Exercises

Python NumPy: Save a NumPy array to a text file

Python NumPy: Array Object Exercise-32 with Solution

Write a Python program to save a NumPy array to a text file.

Sample Solution:-

Python Code:

import numpy as np
a = np.arange(1.0, 2.0, 36.2)
np.savetxt('file.out', a, delimiter=',')

Python Code Editor:

import numpy as np
a = np.arange(1.0, 2.0, 36.2)
np.savetxt('file.out', a, delimiter=',')

Improve this sample solution and post your code through Disqus