Skip to content
masterclass Buddy

NumPy · Function

np.savetxt

numpy.savetxt writes a one- or two-dimensional array to a text file. It supports custom formats, separators, headers, footers, comments, encoding, and automatic gzip output.

Last updated

Syntax

numpy.savetxt(fname, X, fmt='%.18e', delimiter=' ', newline='\n', header='', footer='', comments='# ', encoding=None)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • numpy.loadtxt
  • numpy.save
  • numpy.savez
  • numpy.savez_compressed
  • numpy.genfromtxt
  • numpy.ndarray.tofile

Source: numpy.savetxt — NumPy v2.5 Manual. Checked 2026-11-03.