code: def savetxt(
      fname, arrays, fmt="%.18e", delimiter="\t", header="", footer="", comments="#"
  ):
      r
      if not isinstance(arrays, list):
          arrays = [arrays]
      units = []
      for array in arrays:
          if hasattr(array, "units"):
              units.append(str(array.units))
          else:
              units.append("dimensionless")
      if header != "" and not header.endswith("\n"):
          header += "\n"
      header += " Units\n " + "\t".join(units)
      np.savetxt(
          fname,
          np.transpose(arrays),
          header=header,
          fmt=fmt,
          delimiter=delimiter,
          footer=footer,
          newline="\n",
          comments=comments,
      )
docs: r"""
      Write unyt_arrays with unit information to a text file.
  
      Parameters
      ----------
      fname : str
          The file to write the unyt_arrays to.
      arrays : list of unyt_arrays or single unyt_array
          The array(s) to write to the file.
      fmt : str or sequence of strs, optional
          A single format (%10.5f), or a sequence of formats.
      delimiter : str, optional
          String or character separating columns.
      header : str, optional
          String that will be written at the beginning of the file, before the
          unit header.
      footer : str, optional
          String that will be written at the end of the file.
      comments : str, optional
          String that will be prepended to the ``header`` and ``footer`` strings,
          to mark them as comments. Default: '# ', as expected by e.g.
          ``unyt.loadtxt``.
  
      Examples
      --------
      >>> import unyt as u
      >>> a = [1, 2, 3]*u.cm
      >>> b = [8, 10, 12]*u.cm/u.s
      >>> c = [2, 85, 9]*u.g
      >>> savetxt("sphere.dat", [a,b,c], header='My sphere stuff',
      ...          delimiter="\t")  # doctest: +SKIP